#ifndef ARENA_H #define ARENA_H #define ARENA_INITIAL_COMMIT_SIZE sizeof(struct Arena) #define ARENA_DEFAULT_ALIGNMENT 8 #ifndef ARENA_DEFAULT_RESERVE_SIZE # define ARENA_DEFAULT_RESERVE_SIZE KB(4) #endif // ARENA_DEFAULT_RESERVE_SIZE typedef struct Arena Arena; struct Arena { struct Arena *current; struct Arena *prev; u64 *backing_buffer; u64 base_pos; u64 offset; u64 size; b8 growable; }; STATIC_ASSERT(ARENA_INITIAL_COMMIT_SIZE <= ARENA_DEFAULT_RESERVE_SIZE, arena_default_allocation_size); //= rhjr: arenas internal Arena * arena_initialize(u64 size, b8 growable); internal Arena * arena_initialize_default(); internal void * arena_allocate(Arena *arena, u64 size); #define arena_push_array(arena, type, count) \ (type*) arena_allocate((arena), sizeof(type) * (count)) #define arena_push(arena, type) \ (type*) arena_allocate((arena), sizeof(type)) internal void arena_release(Arena *arena); #endif // ARENA_H