//Memory for several values at once
let count = 3
let buffer = UnsafeMutablePointer<Int>.allocate(
capacity: count)
buffer.initialize(repeating: 0, count: count)
for i in 0 ..< count {
buffer[i] = (i + 1) * 10
}
//buffer[1] is 20
print("buffer[1] is \(buffer[1])")
//Raw memory knows nothing about the type: it is
//asked for BYTES and for an alignment
let raw = UnsafeMutableRawPointer.allocate(
byteCount: 8, alignment: 8)
raw.storeBytes(of: 42, as: Int.self)
let stored = raw.load(as: Int.self)
//stored is 42
print("stored is \(stored)")
//Nothing here is released by itself
buffer.deinitialize(count: count)
buffer.deallocate()
raw.deallocate()
print("memory is released")