CFAllocator Reference

CFAllocator is an opaque type used to allocate and deallocate memory. More...

## Detailed Description

## Data Structures

struct | CFAllocatorContext

## Typedefs

typedef const struct __CFAllocator * | CFAllocatorRef
| A reference to a CFAllocator object.
typedef void *(* | CFAllocatorAllocateCallBack) (CFIndex allocSize, CFOptionFlags hint, void *info)
typedef void(* | CFAllocatorDeallocateCallBack) (void *ptr, void *info)
typedef void *(* | CFAllocatorReallocateCallBack) (void *ptr, CFIndex newsize, CFOptionFlags hint, void *info)
typedef CFIndex(* | CFAllocatorPreferredSizeCallBack) (CFIndex size, CFOptionFlags hint, void *info)
typedef const void *(* | CFAllocatorRetainCallBack) (const void *info)
typedef void(* | CFAllocatorReleaseCallBack) (const void *info)
typedef CFStringRef(* | CFAllocatorCopyDescriptionCallBack) (const void *info)

## Functions

CFAllocatorRef | CFAllocatorCreate (CFAllocatorRef allocator, CFAllocatorContext *context)
void * | CFAllocatorAllocate (CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint)
void | CFAllocatorDeallocate (CFAllocatorRef allocator, void *ptr)
CFIndex | CFAllocatorGetPreferredSizeForSize (CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint)
void * | CFAllocatorReallocate (CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint)
CFAllocatorRef | CFAllocatorGetDefault (void)
void | CFAllocatorSetDefault (CFAllocatorRef allocator)
void | CFAllocatorGetContext (CFAllocatorRef allocator, CFAllocatorContext *context)
CFTypeID | CFAllocatorGetTypeID (void)

## Variables

CFAllocatorRef | kCFAllocatorDefault
CFAllocatorRef | kCFAllocatorSystemDefault
CFAllocatorRef | kCFAllocatorMalloc
CFAllocatorRef | kCFAllocatorMallocZone
CFAllocatorRef | kCFAllocatorNull
CFAllocatorRef | kCFAllocatorUseContext

## Data Structure Documentation

## _CFAllocatorContext

struct _CFAllocatorContext

Data Fields
CFIndex | version |
void * | info |
CFAllocatorRetainCallBack | retain |
CFAllocatorReleaseCallBack | release |
CFAllocatorCopyDescriptionCallBack | copyDescription |
CFAllocatorAllocateCallBack | allocate |
CFAllocatorReallocateCallBack | reallocate |
CFAllocatorDeallocateCallBack | deallocate |
CFAllocatorPreferredSizeCallBack | preferredSize |

## Function Documentation

## CFAllocatorCreate()

CFAllocatorRef CFAllocatorCreate | ( | CFAllocatorRef | allocator,
|  | CFAllocatorContext * | context
| ) |  |

Create a new CFAllocator.

Parameters

  allocator | The allocator used to create this allocator or kCFAllocatorUseContext to use the functions in context.
  context | The new allocator's context functions.

Returns
  A new CFAllocator or NULL in case of failure.

See also
  CFAllocatorContext

## CFAllocatorAllocate()

void * CFAllocatorAllocate | ( | CFAllocatorRef | allocator,
|  | CFIndex | size,
|  | CFOptionFlags | hint
| ) |  |

Allocate new memory.

Parameters

  allocator | The CFAllocator to use.
  size | The number of bytes to allocate.
  hint | Option flags. Currently unused and should be 0.

Returns
  Newly allocated memory of NULL in case of failure.

See also
  CFAllocatorDeallocate()

## CFAllocatorDeallocate()

void CFAllocatorDeallocate | ( | CFAllocatorRef | allocator,
|  | void * | ptr
| ) |  |

Deallocate the memory pointed to by ptr.

Parameters

  allocator | The CFAllocator to use.
  ptr | A pointer previously allocated by CFAllocatorAllocate().

See also
  CFAllocatorAllocate()

## Variable Documentation

## kCFAllocatorDefault

CFAllocatorRef kCFAllocatorDefault

The default allocator and is equivalent to NULL.

See also
  CFAllocatorGetDefault()
  CFAllocatorSetDefault()

Examples
  EXUInt32.c.

## kCFAllocatorSystemDefault

CFAllocatorRef kCFAllocatorSystemDefault

The default system allocator is used internally by GNUstep and is the default allocator if none is been defined.

See also
  CFAllocatorSetDefault()

## kCFAllocatorMalloc

CFAllocatorRef kCFAllocatorMalloc

An allocator that uses the system's malloc, realloc and free functions.

## kCFAllocatorMallocZone

CFAllocatorRef kCFAllocatorMallocZone

Equivalent to kCFAllocatorSystemDefault

## kCFAllocatorNull

CFAllocatorRef kCFAllocatorNull

The NULL allocator does perform any operations. Can be passed as a deallocator if you do not want GNUstep to deallocate the data.

## kCFAllocatorUseContext

CFAllocatorRef kCFAllocatorUseContext

This is a special case allocator directing CFAllocatorCreate() to use the given CFAllocatorContext structure to allocate the new allocator.