We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
md5: 350bc083a2e707af5a997f7350836230
Issue Description:
At the moment we must define a custom allocator for the following code:
let retPointer = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: MemoryLayout<UInt8>.alignment)
let d = Data(bytesNoCopy: retPointer, count: size, deallocator: .custom({ (ptr, size) in ptr.deallocate(bytes: size, alignedTo: 1) }))
It would be nice to have a predefined enum for a deallocator that matches UnsafeMutableRawPointer.allocate
The text was updated successfully, but these errors were encountered:
Comment by Stéphane Lizeray (JIRA)
@parkera @atrick here is the feature request we have been discussing about by mail in the swift-users mailing list
Sorry, something went wrong.
Thanks for filing this.
The same predefined deallocator should work with memory allocated from either:
UnsafeMutablePointer<T>.allocate(capacity:)
or
UnsafeMutableRawPointer.allocate(bytes: alignedTo:)
It just needs to store the size and alignment and invoke:
UnsafeMutableRawPointer.deallocate(bytes: alignedTo:)
No branches or pull requests
Additional Detail from JIRA
md5: 350bc083a2e707af5a997f7350836230
Issue Description:
At the moment we must define a custom allocator for the following code:
let retPointer = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: MemoryLayout<UInt8>.alignment)
let d = Data(bytesNoCopy: retPointer, count: size, deallocator: .custom({ (ptr, size) in
ptr.deallocate(bytes: size, alignedTo: 1)
}))
It would be nice to have a predefined enum for a deallocator that matches UnsafeMutableRawPointer.allocate
The text was updated successfully, but these errors were encountered: