BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):br_allocator
Next|Prev|Up
The Structure
Members
Operations
BrAllocatorSet()
Copy/Assign
Access & Maintenance
Referencing & Lifetime
Initialisation
Construction & Destruction
Supplementary

br_allocator


The Structure

This structure represents the definition of a memory allocation system or memory handler. All BRender's memory allocation is provided by just three functions, which can be specified by the programmer. This is essential in cases where the standard C library functions, which BRender's handler uses by default, are not available. Sometimes, more sophisticated behaviour is desired, or diagnostic features are needed.

The typedef

(See brmem.h for precise declaration and ordering)

Handling Functions

brmem_allocate_cbfn * allocate Memory allocation function

brmem_free_cbfn * free Memory deallocation function

brmem_inquire_cbfn * inquire Memory inquiry function

Supplementary

char * identifier Allocator name

Members

Handling Functions

brmem_allocate_cbfn * allocate

This is a pointer to the memory allocation function (See brmem_allocate_cbfn383). This is called by BrMemAllocate()55.

brmem_free_cbfn * free

This is a pointer to the memory deallocation function (See brmem_free_cbfn385). This is called by BrMemFree()56.

brmem_inquire_cbfn * inquire

This is a pointer to the memory inquiry function (See brmem_inquire_cbfn386). This is called by BrMemInquire()55.

Supplementary

char * identifier

Pointer to unique, zero terminated, character string (or Null if not required). A string constant is recommended.

Operations


BrAllocatorSet()

Description:
Install a new set of memory allocation/deallocation functions.

Declaration:
const br_allocator* BrAllocatorSet(const br_allocator* newal)

Arguments:
const br_allocator * newal

A pointer to an instance of a br_allocator99 structure.

Result:
const br_allocator *

Returns a pointer to the old br_allocator99 structure.


Copy/Assign

Beware of copying the structure if identifier has been allocated from the heap.

Access & Maintenance

While the structure is the current allocator (most recently passed to BrAllocatorSet()100) the members should not be changed. No maintenance required.

Referencing & Lifetime

The structure must remain valid until a new allocator is passed to BrAllocatorSet()100.

Initialisation

The members should be set before the structure is passed to BrAllocatorSet()100.

Construction & Destruction

The structure should ideally be statically constructed.

If constructed by `malloc' ensure it is destroyed by `free', i.e. the memory allocation handler that provided the storage should be the one to reclaim it. Be careful if macros have been used to redefine malloc to use BRender's allocator. Generally, be aware of any constraints one handler may place on memory allocated by another handler.

Supplementary

The identifier may be used to determine the current handler in use.


Generated with
CERN WebMaker