|
cbase 1.50.0
C/C++ Static Template
|
High-performance virtual memory Arena Allocator. More...


Go to the source code of this file.
Classes | |
| struct | MemArena |
| A virtual memory-backed linear allocator. More... | |
| struct | MemArenaTemp |
| A temporary snapshot of an arena's state. More... | |
Macros | |
| #define | MEM_ARENA_ALIGNMENT 8 |
| The default byte alignment for memory pushed onto the arena. | |
| #define | PUSH_STRUCT(arena, type) |
| Type-Safe Allocation Macros. | |
| #define | PUSH_ARRAY(arena, type, count) |
| Pushes an array of structs of type T onto the arena. | |
| #define | PUSH_STRUCT_ALIGNED(arena, type, alignment) |
| Pushes a struct with custom memory alignment. | |
| #define | PUSH_ARRAY_ALIGNED(arena, type, count, alignment) |
| Pushes an array of structs with custom memory alignment. | |
| #define | PUSH_CSTR(arena, cstr) |
| Copies a NUL-terminated C string into the arena. | |
Typedefs | |
| typedef struct MemArena | MemArena |
| A virtual memory-backed linear allocator. | |
| typedef struct MemArenaTemp | MemArenaTemp |
| A temporary snapshot of an arena's state. | |
Functions | |
| MemArena | mem_arena_create (usize reserve_size) |
| Initializes a new virtual memory Arena. | |
| void * | mem_arena_push (MemArena *arena, usize size) |
| Allocates bytes sequentially on the arena without zeroing. | |
| void * | mem_arena_push_zero (MemArena *arena, usize size) |
| Allocates bytes and explicitly zero-initializes them. | |
| void * | mem_arena_push_aligned (MemArena *arena, usize size, usize alignment) |
| Allocates bytes with a specific custom alignment. | |
| char * | mem_arena_push_cstr (MemArena *arena, const char *str, usize len) |
| Copies a C string into the arena and appends a NUL terminator. | |
| void | mem_arena_pop_to (MemArena *arena, usize pos) |
| Rewinds the arena's pointer to a specific offset. | |
| void | mem_arena_clear (MemArena *arena) |
| Resets the arena pointer to zero, freeing all allocations in O(1). | |
| void | mem_arena_clear_and_decommit (MemArena *arena) |
| Clears the arena and returns all committed physical RAM to the OS. | |
| void | mem_arena_release (MemArena *arena) |
| Returns all virtual memory back to the operating system. | |
| struct MemAllocator | mem_arena_allocator (MemArena *arena) |
| Wraps a MemArena in the generic MemAllocator interface. | |
| MemArenaTemp | mem_arena_temp_begin (MemArena *arena) |
| Temporary Memory API. | |
| void | mem_arena_temp_end (MemArenaTemp temp) |
Restores the arena to the position saved in temp. | |
High-performance virtual memory Arena Allocator.
Reserves a massive block of virtual address space upfront but only commits physical RAM as the bump pointer advances. Eliminates individual malloc/free overhead and memory fragmentation entirely.
Definition in file mem_arena.h.