19 lines
424 B
C
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))
|