aoc2024/stdlib/include/arena.h
2024-12-05 21:22:19 +01:00

19 lines
424 B
C

#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))