#ifndef AMALGAM_SCOPED_ALLOCATOR_H #define AMALGAM_SCOPED_ALLOCATOR_H #include "defs.h" #include "misc.h" #include "types.h" #include "buffer.h" struct ScopedAllocatorNode { char *data; usize size; ScopedAllocatorNode *next; }; struct ScopedAllocator { ScopedAllocatorNode head; ScopedAllocatorNode *current; Buffer/**/ mems; /* TODO: Use linked-list instead, since the elements are dynamically allocated anyways */ /* Find another way to store mutexes */ Buffer/**/ mutexes; }; CHECK_RESULT int scoped_allocator_node_init(ScopedAllocatorNode *self); void scoped_allocator_node_deinit(ScopedAllocatorNode *self); CHECK_RESULT int scoped_allocator_init(ScopedAllocator *self); void scoped_allocator_deinit(ScopedAllocator *self); CHECK_RESULT int scoped_allocator_alloc(ScopedAllocator *self, usize size, void **mem); CHECK_RESULT int scoped_allocator_add_mem(ScopedAllocator *self, usize *result_index); CHECK_RESULT int scoped_allocator_create_mutex(ScopedAllocator *self, amal_mutex **mutex); #endif