BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):brmem_allocate_cbfn
The Call-Back Function


The Call-Back Function

This type defines a memory allocation function, primarily intended for the allocate member of the br_allocator
99 structure.

The typedef

(See brmem.h for a precise declaration)

void * brmem_allocate_cbfn(br_size_t,br_uint_8) Allocator



An application defined call-back function returning a pointer to newly allocated memory of specified size and type.

void* BR_CALLBACK CBFnMemAllocate(br_size_t size, br_uint_8 type)

br_size_t size

Size in bytes of memory block required. More bytes may be allocated, but the caller will only use the first size bytes. Zero is a valid value.

br_uint_8 type

Class (type ID) of memory required. Although it is possible for the class to be ignored, it may be used for diagnostic purposes, or could be used to provide a more efficient allocation scheme. See Memory Classes for a description of possible values.

The diagnostic handler has been setup (BrDiagHandlerSet()
116). BRender has not necessarily completed initialisation. This may not be the first allocator to have been called. BRender is the only direct caller of this function.

Obtain a fixed, contiguous, persistent, readable, writable, non-volatile area of memory of at least the size specified (even if zero), that will remain so until a corresponding call of CBFnMemFree()385 has occurred.

void *

The address of a block of memory of the required size. If the request cannot be satisfied, return Null.

No assumption can be made concerning any relation between the address returned by this call and any previous or subsequent call.

Although BRender's default diagnostic handling system does not use the memory handler, if you supply a diagnostic handler that does, you may have to handle memory allocation failures directly.

The value returned by CBFnMemInquire()386 does not guarantee the subsequent success or failure of CBFnMemAllocate()383.

See stdmem.c for examples of memory allocation functions.

See Also:
CBFnMemFree()385, CBFnMemInquire()386.

Generated with CERN WebMaker