diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-16 02:03:12 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-16 02:03:12 +0200 |
commit | 43b04a1bfaecfabe8b3460575db7be5d592f896b (patch) | |
tree | 86c337e90f4b4238ab73dd698f470cf3482a0de8 /lib/alloc/arena_free.c | |
parent | bbbeab43e067a7f009b74df72ed9b083f3ecef58 (diff) |
implement arena allocators
Diffstat (limited to 'lib/alloc/arena_free.c')
-rw-r--r-- | lib/alloc/arena_free.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/alloc/arena_free.c b/lib/alloc/arena_free.c new file mode 100644 index 0000000..dc2b45e --- /dev/null +++ b/lib/alloc/arena_free.c @@ -0,0 +1,20 @@ +#include <sys/mman.h> + +#include <stdlib.h> + +#include "alloc.h" +#include "macros.h" + +void +arena_free(arena *a) +{ + ASSUME(a != nullptr); + + struct _region *cur, *next; + for (cur = a->_head; cur != nullptr; cur = next) { + next = cur->next; + munmap(cur->data, cur->cap); + free(cur); + } + a->_head = nullptr; +} |