Obtains the number of bytes likely to be allocated upon a specific request.


func CFAllocatorGetPreferredSizeForSize(_ allocator: CFAllocator!, _ size: CFIndex, _ hint: CFOptionFlags) -> CFIndex



The allocator to use, or NULL for the default allocator.


The number of bytes to allocate. If the value is 0 or less, the result is the same value.


A bitfield of type CFOptionsFlags. Pass flags to the allocator that suggest how memory is to be allocated. 0 indicates no hints. No hints are currently defined, only 0 should be passed for this argument.

Return Value

The number of bytes likely to be allocated upon a specific request.


The return value depends on the allocator's internal allocation strategy, and will be equal to or larger than size. Calling this function may help you better match your memory allocation or reallocation strategy to that of the allocator.

Note that the return value depends on the internal implementation of the allocator and the results may change from release to release or from platform to platform.

If no function callback is assigned to the preferredSize field of the allocator's context (see the CFAllocatorContext structure), then the value of size is returned.

See Also