BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):brmem_allocate_cbfn
Next|Prev|Up
The Call-Back Function
Specification
CBFnMemAllocate()

brmem_allocate_cbfn


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

Specification


CBFnMemAllocate()

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

Declaration:
void* BR_CALLBACK CBFnMemAllocate(br_size_t size, br_uint_8 type)

Arguments:
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.

Preconditions:
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.

Effects:
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.

Result:
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.

Remarks:
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.

Example:
See stdmem.c for examples of memory allocation functions.

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



Generated with CERN WebMaker