void * mem_ctx_t
type shared externally
bool(* mem_parse_callback_t)(void *data, uint8_t *addr, bool allocated, size_t size)
function called for each chunk found in the heap.
mem_ctx_t mem_init(void *heap_start, size_t heap_size)
initializes the heap for this allocator
void * mem_alloc(mem_ctx_t ctx, size_t nb_bytes)
allocates a buffer of the given size, if possible
void mem_parse(mem_ctx_t ctx, mem_parse_callback_t callback, void *dat)
parse the heap
void mem_free(mem_ctx_t ctx, void *ptr)
frees the given buffer
void mem_stat(mem_ctx_t *ctx, mem_stat_t *stat)
function used to get statistics (nb chunks, nb allocated chunks, total size) about the heap
this structure, filled by mem_stat
size_t allocated_size
nb bytes allocated in the heap (including headers)
size_t total_size
total size of the heap (including allocator internal data)
uint32_t nb_allocated
number of allocated chunks
uint32_t nb_chunks
total number of chunks