From 1f28c3c733ea3ae4234bff91e1c55e61b1ee3e96 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Jul 2019 01:25:05 +0200 Subject: Starting on asm, implementing extern function call so progress is visible --- include/std/arena_allocator.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/std/arena_allocator.h (limited to 'include/std/arena_allocator.h') 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/**/ 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 -- cgit v1.2.3