Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- func test(count: Int) -> UInt8 {
- precondition(count >= 1)
- let ptr = UnsafeMutableRawPointer.allocate(byteCount: count, alignment: 1)
- ptr.storeBytes(of: 0, toByteOffset: 0, as: UInt8.self)
- let data = Data(bytesNoCopy: ptr, count: count, deallocator: .none)
- ptr.storeBytes(of: 13, toByteOffset: 0, as: UInt8.self)
- return data[0]
- }
- for i in 1...24 {
- print("\(i): \(test(count: i))")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement