aoc2024/stdlib/include/arena.h

19 lines
424 B
C
Raw Normal View History

2024-12-05 20:22:19 +00:00
#pragma once
#include <common.h>
typedef struct arena {
void* ptr;
usize available;
usize capacity;
} arena;
// The capacity has to be page-aligned
arena arena_init(usize capacity);
// The available size will be rounded up to a page boundary
// Will not grow beyond its capacity
void arena_ensure(arena* arena, usize available);
#define ARENA_ENSURE(T, arena, available) arena_ensure(arena, (available) * sizeof(T))