Implement memory context with main and temp arenas

This commit is contained in:
Abdelrahman Said
2024-03-24 07:59:46 +00:00
parent 063bc03974
commit 0c07437ef2
2 changed files with 109 additions and 0 deletions

27
mem/include/ctx/mem_ctx.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef MEM_CTX_H
#define MEM_CTX_H
#include "mem_arena.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef enum {
CTX_DEST_BUFFER_MAIN,
CTX_DEST_BUFFER_TEMP,
COUNT_CTX_DEST_BUFFER,
} CTXDestBuffer;
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);
void wapp_mem_ctx_clear(CTXDestBuffer buffer);
void wapp_mem_ctx_free(void);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !MEM_CTX_H