diff options
author | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-02-25 11:02:46 +1100 |
---|---|---|
committer | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-02-25 11:02:46 +1100 |
commit | 4b9ab2ec5acf2ecf2e96c38733a835b964664171 (patch) | |
tree | 3a20f08c99e9f5036bccf7916cec56fbb7fd0ec0 /src/std/mem.h | |
parent | 1e1facd09ade50ffaf421cffe53ff7ddddab2793 (diff) |
add an arena allocator first impl
Diffstat (limited to 'src/std/mem.h')
-rw-r--r-- | src/std/mem.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/std/mem.h b/src/std/mem.h index 74222a7..75b6d2a 100644 --- a/src/std/mem.h +++ b/src/std/mem.h @@ -9,6 +9,14 @@ */ #pragma once -#include "defines.h" +#include <stddef.h> -typedef void* (*alloc)(size_t amount);
\ No newline at end of file +// Inspired by https://nullprogram.com/blog/2023/09/27/ +typedef struct arena { + char* begin; + char* end; +} arena; + +arena arena_create(void* backing_buffer, size_t capacity); +void *arena_alloc(arena* a, size_t size); +void *arena_alloc_align(arena* a, size_t size, size_t align); |