67#define MEM_ARENA_ALIGNMENT 8
331#define PUSH_STRUCT(arena, type) ((type *)mem_arena_push_zero((arena), sizeof(type)))
343#define PUSH_ARRAY(arena, type, count) \
344 ((type *)mem_arena_push_zero((arena), sizeof(type) * (count)))
354#define PUSH_STRUCT_ALIGNED(arena, type, alignment) \
355 ((type *)mem_arena_push_aligned((arena), sizeof(type), (alignment)))
366#define PUSH_ARRAY_ALIGNED(arena, type, count, alignment) \
367 ((type *)mem_arena_push_aligned((arena), sizeof(type) * (count), (alignment)))
386#define PUSH_CSTR(arena, cstr) (mem_arena_push_cstr((arena), (cstr), strlen(cstr)))
Context detection, compiler abstractions, utility macros, and data structures.
Core fixed-width type aliases and memory size constants.
#define C_LINKAGE_END
Closes a C linkage block for C++ compilers (Empty in C).
#define C_LINKAGE_BEGIN
Opens a C linkage block for C++ compilers (Empty in C).
void mem_arena_clear(MemArena *arena)
Resets the arena pointer to zero, freeing all allocations in O(1).
void mem_arena_temp_end(MemArenaTemp temp)
Restores the arena to the position saved in temp.
void mem_arena_release(MemArena *arena)
Returns all virtual memory back to the operating system.
void * mem_arena_push_zero(MemArena *arena, usize size)
Allocates bytes and explicitly zero-initializes them.
void mem_arena_clear_and_decommit(MemArena *arena)
Clears the arena and returns all committed physical RAM to the OS.
void * mem_arena_push_aligned(MemArena *arena, usize size, usize alignment)
Allocates bytes with a specific custom alignment.
void * mem_arena_push(MemArena *arena, usize size)
Allocates bytes sequentially on the arena without zeroing.
void mem_arena_pop_to(MemArena *arena, usize pos)
Rewinds the arena's pointer to a specific offset.
struct MemAllocator mem_arena_allocator(MemArena *arena)
Wraps a MemArena in the generic MemAllocator interface.
char * mem_arena_push_cstr(MemArena *arena, const char *str, usize len)
Copies a C string into the arena and appends a NUL terminator.
MemArenaTemp mem_arena_temp_begin(MemArena *arena)
Temporary Memory API.
MemArena mem_arena_create(usize reserve_size)
Initializes a new virtual memory Arena.
An abstract allocator interface.
A virtual memory-backed linear allocator.
A temporary snapshot of an arena's state.