Add arena allocator library
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m44s

This commit is contained in:
2026-02-25 18:20:59 +01:00
parent 4e09296709
commit f846edf0ff
11 changed files with 138 additions and 0 deletions

25
libarena/arena.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef _LIBARENA_ARENA_H
#define _LIBARENA_ARENA_H
#include <stddef.h>
#define ARENA_CHUNK_CAPACITY (8 * 1024)
struct arena_chunk {
struct arena_chunk* next;
size_t capacity;
size_t size;
uintptr_t memory[];
};
struct arena {
struct arena_chunk *begin, *end;
};
void arena_reset (struct arena* arena);
void arena_destroy (struct arena* arena);
void* arena_malloc (struct arena* arena, size_t size);
#endif // _LIBARENA_ARENA_H