Created
June 17, 2019 07:02
-
-
Save sonsongithub/fffb226b9eb13c6976483c4c886e77d5 to your computer and use it in GitHub Desktop.
alloc_test.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Cocoa | |
| import Foundation | |
| //var buffer: UnsafeMutablePointer<unichar> = UnsafeMutablePointer<unichar>.allocate(capacity: 3) | |
| // | |
| //Array.with) | |
| var buffer = [unichar](repeating: 0, count: 3) | |
| let p = UnsafeMutablePointer<unichar>(&buffer) | |
| buffer[0] = unichar(UInt8(ascii: "a")) | |
| buffer[1] = unichar(UInt8(ascii: "b")) | |
| buffer[2] = unichar(UInt8(ascii: "c")) | |
| let x = p + 1 | |
| print(x.pointee) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment