Subastra
|
The Arena allocator is a single continous block of memory. More...
#include <arena.h>
Public Member Functions | |
#define | arena_alloc_ty(ty, arena, sz) (ty *)arena_alloc(arena, sz * sizeof(ty)) |
Allocate a typed array inside the arena. | |
Static Public Member Functions | |
static void | arena_init (arena_t *arena, allocator_t fallback, sz size) |
Initializes the memory arena. | |
static void | arena_clear (arena_t *arena) |
Clears the memory arena entirely and marks all the memory as poison. Importantly, does not release memory. O(1) | |
static void | arena_cleanup (arena_t *arena) |
Release all the allocated memory. | |
static allocator_t | arena_as_allocator (arena_t *arena) |
A generic function to type-erase the arena_t into an allocator_t. | |
Data Fields | |
allocator_t | fallback |
The allocator that the arena will forward all the allocation requests to. | |
byte * | root |
The starting address of the arena. | |
sz | size |
The total amount of bytes the arena can handle. | |
sz | offset |
The next location to put the data at. | |
The Arena allocator is a single continous block of memory.
Any deletions from the block do nothing except mark the memory as poisoned. The intention to use the arena for objects that share a lifetime, for instance all objects that live for 1 frame.
|
static |
A generic function to type-erase the arena_t into an allocator_t.
Clears the memory arena entirely and marks all the memory as poison. Importantly, does not release memory. O(1)
|
static |
Initializes the memory arena.
allocator_t fallback |
The allocator that the arena will forward all the allocation requests to.
sz offset |
The next location to put the data at.
byte* root |
The starting address of the arena.
sz size |
The total amount of bytes the arena can handle.