diff options
Diffstat (limited to 'include/std/arena_allocator.h')
-rw-r--r-- | include/std/arena_allocator.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/std/arena_allocator.h b/include/std/arena_allocator.h new file mode 100644 index 0000000..30147c8 --- /dev/null +++ b/include/std/arena_allocator.h @@ -0,0 +1,29 @@ +#ifndef AMALGAM_ARENA_ALLOCATOR_H +#define AMALGAM_ARENA_ALLOCATOR_H + +#include "defs.h" +#include "misc.h" +#include "types.h" +#include "buffer.h" + +struct ArenaAllocatorNode { + char *data; + usize size; + ArenaAllocatorNode *next; +}; + +struct ArenaAllocator { + ArenaAllocatorNode head; + ArenaAllocatorNode *current; + Buffer/*<void*>*/ mems; +}; + +CHECK_RESULT int arena_allocator_node_init(ArenaAllocatorNode *self); +void arena_allocator_node_deinit(ArenaAllocatorNode *self); + +CHECK_RESULT int arena_allocator_init(ArenaAllocator *self); +void arena_allocator_deinit(ArenaAllocator *self); +CHECK_RESULT int arena_allocator_alloc(ArenaAllocator *self, usize size, void **mem); +CHECK_RESULT int arena_allocator_add_mem(ArenaAllocator *self, usize *result_index); + +#endif |