|
Banjo API 0.0.1
C99 game development API
|
Data Structures | |
| struct | bj_memory_callbacks |
Typedefs | |
| typedef void *(* | bj_malloc_fn) (void *p_user_data, size_t size) |
| typedef void *(* | bj_realloc_fn) (void *p_user_data, void *p_original, size_t size) |
| typedef void(* | bj_free_fn) (void *p_user_data, void *p_memory) |
| typedef struct bj_memory_callbacks | bj_memory_callbacks |
Functions | |
| void * | bj_malloc (size_t size) |
| void * | bj_calloc (size_t size) |
| void * | bj_realloc (void *p_memory, size_t size) |
| void | bj_free (void *p_memory) |
| void | bj_set_memory_defaults (const bj_memory_callbacks *p_allocator) |
| void | bj_unset_memory_defaults (void) |
| void * | bj_memcpy (void *p_dest, const void *p_src, size_t mem_size) |
| void * | bj_memmove (void *p_dest, const void *p_src, size_t mem_size) |
| int | bj_memcmp (const void *p_block_a, const void *p_block_b, size_t size) |
| void | bj_memset (void *p_dest, uint8_t value, size_t mem_size) |
| void | bj_memzero (void *p_dest, size_t mem_size) |
| struct bj_memory_callbacks |
Custom allocation callbacks.
This structure holds function pointers for allocation, reallocation, and deallocation callbacks along with user data.
These callbacks can be assigned per-object or set globally with bj_set_memory_defaults.
| Data Fields | ||
|---|---|---|
| bj_malloc_fn | fn_allocation | Allocation function pointer. |
| bj_free_fn | fn_free | Deallocation function pointer. |
| bj_realloc_fn | fn_reallocation | Reallocation function pointer. |
| void * | p_user_data | General purpose context data. |
| typedef void(* bj_free_fn) (void *p_user_data, void *p_memory) |
Memory free callback.
Used in bj_memory_callbacks to set the function used for custom deallocations.
| p_user_data | General purpose context data. |
| p_memory | Object memory to dispose. |
| typedef void *(* bj_malloc_fn) (void *p_user_data, size_t size) |
Memory allocation callback.
Used in bj_memory_callbacks to set the function used for custom allocations.
| p_user_data | General purpose context data. |
| size | Allocation size in bytes requested by the caller. |
| typedef struct bj_memory_callbacks bj_memory_callbacks |
Custom allocation callbacks.
This structure holds function pointers for allocation, reallocation, and deallocation callbacks along with user data.
These callbacks can be assigned per-object or set globally with bj_set_memory_defaults.
| typedef void *(* bj_realloc_fn) (void *p_user_data, void *p_original, size_t size) |
Memory reallocation callback.
Used in bj_memory_callbacks to set the function used for custom reallocations.
| p_user_data | General purpose context data. |
| p_original | Initial object to reallocate. |
| size | Allocation size in bytes requested by the caller. |
| void * bj_calloc | ( | size_t | size | ) |
Allocate size bytes of zero-initialized memory.
The returned memory is set to zero bytes.
| [in] | size | Number of bytes to allocate. |
| void bj_free | ( | void * | p_memory | ) |
Free a previously allocated memory block.
| [in] | p_memory | Pointer to memory to free. |
| void * bj_malloc | ( | size_t | size | ) |
Allocate size bytes of memory.
| [in] | size | Number of bytes to allocate. |
| int bj_memcmp | ( | const void * | p_block_a, |
| const void * | p_block_b, | ||
| size_t | size ) |
Compare two memory blocks.
| [in] | p_block_a | Pointer to first memory block. |
| [in] | p_block_b | Pointer to second memory block. |
| [in] | size | Number of bytes to compare. |
| void * bj_memcpy | ( | void * | p_dest, |
| const void * | p_src, | ||
| size_t | mem_size ) |
Copy mem_size bytes from p_src to p_dest.
| [in] | p_dest | Destination pointer. |
| [in] | p_src | Source pointer. |
| [in] | mem_size | Number of bytes to copy. |
| void * bj_memmove | ( | void * | p_dest, |
| const void * | p_src, | ||
| size_t | mem_size ) |
Move mem_size bytes from p_src to p_dest.
Similar to bj_memcpy but handles overlapping memory regions safely.
| [in] | p_dest | Destination pointer. |
| [in] | p_src | Source pointer. |
| [in] | mem_size | Number of bytes to move. |
| void bj_memset | ( | void * | p_dest, |
| uint8_t | value, | ||
| size_t | mem_size ) |
Fill mem_size bytes at p_dest with value.
| [in] | p_dest | Destination pointer. |
| [in] | value | Byte value to fill. |
| [in] | mem_size | Number of bytes to fill. |
| void bj_memzero | ( | void * | p_dest, |
| size_t | mem_size ) |
Zero out mem_size bytes at p_dest.
Effectively calls bj_memset with zero.
| [in] | p_dest | Destination pointer. |
| [in] | mem_size | Number of bytes to zero. |
| void * bj_realloc | ( | void * | p_memory, |
| size_t | size ) |
Reallocate a memory block to a new size.
| [in] | p_memory | Pointer to previously allocated memory. |
| [in] | size | Number of bytes to allocate. |
| void bj_set_memory_defaults | ( | const bj_memory_callbacks * | p_allocator | ) |
Set the global default memory allocators.
If p_allocator is NULL, resets to system defaults (malloc, realloc, free).
| [in] | p_allocator | Pointer to custom allocator callbacks. |
| void bj_unset_memory_defaults | ( | void | ) |
Reset the global default allocators to system defaults.
Sets allocators back to standard system functions (malloc, realloc, free).