diff --git a/mem/include/ctx/mem_ctx.h b/mem/include/ctx/mem_ctx.h index 3d9e94d..aea0fc4 100644 --- a/mem/include/ctx/mem_ctx.h +++ b/mem/include/ctx/mem_ctx.h @@ -1,6 +1,7 @@ #ifndef MEM_CTX_H #define MEM_CTX_H +#include "mem_allocator.h" #include "mem_arena.h" #ifdef __cplusplus @@ -14,6 +15,7 @@ typedef enum { COUNT_CTX_DEST_BUFFER, } CTXDestBuffer; +Allocator wapp_mem_ctx_allocator(CTXDestBuffer buffer); void wapp_mem_ctx_init(u64 main_buf_capacity, u64 temp_buf_capacity); void *wapp_mem_ctx_alloc(CTXDestBuffer buffer, u64 size); void *wapp_mem_ctx_alloc_aligned(CTXDestBuffer buffer, u64 size, u64 alignment); diff --git a/mem/src/ctx/mem_ctx.c b/mem/src/ctx/mem_ctx.c index 2791755..4cef187 100644 --- a/mem/src/ctx/mem_ctx.c +++ b/mem/src/ctx/mem_ctx.c @@ -16,6 +16,11 @@ internal MemCTX g_context = {0}; internal Arena *get_arena(CTXDestBuffer buffer); +Allocator wapp_mem_ctx_allocator(CTXDestBuffer buffer) { + Arena *arena = get_arena(buffer); + return wapp_mem_arena_allocator(arena); +} + void wapp_mem_ctx_init(u64 main_buf_capacity, u64 temp_buf_capacity) { g_context.main_initialised = wapp_mem_arena_init(&g_context.main, main_buf_capacity);