|
CNum 0.2.1
CPU-optimized ML library for C++
|
A "mini-heap" used for thread local memory allocation. More...
Functions | |
| arena_t * | arena_init (uint32_t blocks_to_allocate) |
| Initialize Arena. | |
| arena_view_t | arena_malloc (arena_t *arena, size_t bytes, size_t type_size) |
| Arena manual allocation with malloc fallback. | |
| void | arena_clear (arena_t *arena) |
| Zero out an arena's memory. | |
| void | arena_free (arena_t *arena) |
| Free all memory associated with an arena. | |
A "mini-heap" used for thread local memory allocation.
| void arena_clear | ( | arena_t * | arena | ) |
Zero out an arena's memory.
This function does not use memset on the entire range of the arena's memory, but rather zeros the memory up to the internal pointer that keeps track of where the in the arena's memory the next allocation would take place. As this arena's implementation is intentionally simple, allocations are linear, so the memory behind this pointer is all of the previously allocated blocks.
| arena | Pointer to an arena |
| void arena_free | ( | arena_t * | arena | ) |
Free all memory associated with an arena.
| arena_t * arena_init | ( | uint32_t | blocks_to_allocate | ) |
Initialize Arena.
| blocks_to_allocate | The size of the arena in blocks |
| arena_view_t arena_malloc | ( | arena_t * | arena, |
| size_t | bytes, | ||
| size_t | type_size ) |
Arena manual allocation with malloc fallback.
This function attempts to allocated memory in the heap and return a view that memory, but in the case that the arena is out of space will fall back on the standard malloc, but still return an arena_view_t
| arena | Pointer to an arena |
| bytes | The number of bytes to allocate |
| type_size | The size of the data type being stored (for the view) |