#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
Go to the source code of this file.
◆ ARENA_BLOCK_SIZE
| #define ARENA_BLOCK_SIZE 64 |
The block size of the arena.
Used for detirmining padding of allocated memory. It is best to keep this the size of a cache line generally
◆ arena_t
◆ arena_view_t
◆ arena_clear()
| 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.
- Parameters
-
◆ arena_free()
Free all memory associated with an arena.
◆ arena_init()
| arena_t * arena_init |
( |
uint32_t | blocks_to_allocate | ) |
|
Initialize Arena.
- Parameters
-
| blocks_to_allocate | The size of the arena in blocks |
- Returns
- A pointer to an arena
◆ arena_malloc()
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
- Parameters
-
| 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) |
- Returns
- A view of the allocated memory
◆ arena_view_reset()
Free memory associated with an arena_view (within the arena itself).