Creates an allocator object.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Core Foundation
Declaration
CFAllocator Ref CFAllocatorCreate(CFAllocator Ref allocator, CFAllocator Context *context);
Parameters
allocator
The existing allocator to use to allocate memory for the new allocator. Pass the
k
constant for this parameter to allocate memory using the appropriate function callback specified in theCFAllocator Use Context context
parameter. PassNULL
ork
to allocate memory for the new allocator using the default allocator.CFAllocator Default context
A structure of type
CFAllocator
. The fields of this structure hold (among other things) function pointers to callbacks used for allocating, reallocating, and deallocating memory.Context
Return Value
The new allocator object, or NULL
if there was a problem allocating memory. Ownership follows the The Create Rule.
Discussion
You use this function to create custom allocators which you can then pass into various Core Foundation object-creation functions. You must implement a function callback that allocates memory and assign it to the allocate
field of this structure. You typically also implement deallocate, reallocate, and preferred-size callbacks.