Skip to content

[SR-2468] Add a predefined enum for a deallocator that matches UnsafeMutableRawPointer.allocate in Data(bytesNoCopy:count:deallocator) #4334

Open
@swift-ci

Description

@swift-ci
Previous ID SR-2468
Radar radar://27987799
Original Reporter slizeray (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Improvement, SDKOverlay
Assignee None
Priority Medium

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions