Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sonsongithub/fffb226b9eb13c6976483c4c886e77d5 to your computer and use it in GitHub Desktop.

Select an option

Save sonsongithub/fffb226b9eb13c6976483c4c886e77d5 to your computer and use it in GitHub Desktop.
alloc_test.swift
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