malloc
and free
). Note that not all development systems provide any inquiry functions, so in some cases the corresponding, default BRender function will return zero. Given the vagaries of what is meant by `available memory', the application programmer is expected to implement this function themselves if its behaviour is critical.The following two functions are provided for efficient initialisation and copying of word aligned memory.
A pointer to the block to be filled.
Value to fill the block with.
Size of block (number of 32-bit words).
Description:
Fast fill a block of memory.BrBlockFill()
void BrBlockFill(void* dest_ptr, int value, int dwords)
void * dest_ptr
int value
int dwords
BrBlockCopy()
53
Destination pointer.
Source pointer.
Size of block to copy (number of 32-bit words).
Description:
Copy a block of memory. The source and destination blocks must not overlap.BrBlockCopy()
void BrBlockCopy(void* dest_ptr, const void* src_ptr, int dwords)
void * dest_ptr
const void * src_ptr
int dwords
BrBlockFill()
53
Memory classes are defined by name and number. The following symbols define the number of each BRender memory class:
BR_MEMORY
prefix, thus BR_MEMORY_LIGHT
has an identifier of "LIGHT"
.
The applications programmer may also indirectly request memory using classes between BR_MEMORY_APPLICATION
and BR_MEMORY_MAX-1
(inclusive). BR_MEMORY_APPLICATION
should be used for general heap requirements (like malloc()
). Classes BR_MEMORY_APPLICATION+1
and onwards are reserved for user defined classes (see br_resource_class
324
BrResClassAdd()
325
).
BR_MEMORY_APPLICATION
.
Memory type.
Returns memory available in bytes.
Size of memory block to be allocated.
Memory type.
Returns a pointer to the allocated memory, or NULL is unsuccessful.
Number of elements to allocate.
Size of each element.
Memory type.
Returns a pointer to the allocated memory, or NULL is unsuccessful.
A pointer to the source string.
Returns a pointer to the new copy of the string.
A pointer to the block of memory to deallocate.
The application will typically need to do this for platforms that don't have the standard C library functions (
Description:
Find the amount of memory available of a given type.BrMemInquire()
br_size_t BrMemInquire(br_uint_8 type)
br_uint_8 type
br_size_t
Description:
Allocate memory.BrMemAllocate()
void* BrMemAllocate(br_size_t size, br_uint_8 type)
br_size_t size
br_uint_8 type
void *
Description:
Allocate and clear memory.BrMemCalloc()
void* BrMemCalloc(int nelems, br_size_t size, br_uint_8 type)
int nelems
br_size_t size
br_uint_8 type
void *
Description:
Duplicate a string.BrMemStrDup()
char* BrMemStrDup(const char* str)
const char * str
char *
Description:
Deallocate memory.BrMemFree()
void BrMemFree(void* block)
void * block
Memory Allocation Handler
BRender provides the facility for the application to specify their own memory allocation functions, through which all BRender's memory allocation is performed. A static br_allocator
99 structure, containing pointers to an allocator, deallocator and inquiry function, is defined and engaged using
BrAllocatorSet()
100malloc()
etc.), and in cases where simple memory allocation is not appropriate due to limited memory space or performance. Memory Pools
Pools are a flexible way of allocating memory from a class, whereas resource classes permit structured allocation. See br_pool
299 for more information.
Generated with CERN WebMaker