Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
memory.h File Reference

All memory-related functions, including custom allocators.

#include <banjo/api.h>
Include dependency graph for memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bj_memory_callbacks
 Custom allocation callbacks. More...
 

Typedefs

typedef void *(* bj_malloc_fn) (void *p_user_data, size_t size)
 Memory allocation callback.
 
typedef void *(* bj_realloc_fn) (void *p_user_data, void *p_original, size_t size)
 Memory reallocation callback.
 
typedef void(* bj_free_fn) (void *p_user_data, void *p_memory)
 Memory free callback.
 
typedef struct bj_memory_callbacks bj_memory_callbacks
 Custom allocation callbacks.
 

Functions

void * bj_malloc (size_t size)
 Allocate size bytes of memory.
 
void * bj_calloc (size_t size)
 Allocate size bytes of zero-initialized memory.
 
void * bj_realloc (void *p_memory, size_t size)
 Reallocate a memory block to a new size.
 
void bj_free (void *p_memory)
 Free a previously allocated memory block.
 
void bj_memory_set_defaults (const bj_memory_callbacks *p_allocator)
 Set the global default memory allocators.
 
void bj_memory_unset_defaults (void)
 Reset the global default allocators to system defaults.
 
void * bj_memcpy (void *p_dest, const void *p_src, size_t mem_size)
 Copy mem_size bytes from p_src to p_dest.
 
void * bj_memmove (void *p_dest, const void *p_src, size_t mem_size)
 Move mem_size bytes from p_src to p_dest.
 
int bj_memcmp (const void *p_block_a, const void *p_block_b, size_t size)
 Compare two memory blocks.
 
void bj_memset (void *p_dest, uint8_t value, size_t mem_size)
 Fill mem_size bytes at p_dest with value.
 
void bj_memzero (void *p_dest, size_t mem_size)
 Zero out mem_size bytes at p_dest.