From c200dd832789afa298ba45e0b9efdec96c0e92cc Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sun, 5 Dec 2021 11:55:10 -0800 Subject: Chore: simplified allocator interfaces. I was never happy with the allocator/reallocator split. It was originally designed to accomodate things like arenas that don't free. But the majority of the time you don't care about this. --- src/base/mem/arena.c | 12 ++++++++++-- src/base/mem/interface.c | 7 +------ 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/base/mem') diff --git a/src/base/mem/arena.c b/src/base/mem/arena.c index 37e7b56..7fe036a 100644 --- a/src/base/mem/arena.c +++ b/src/base/mem/arena.c @@ -31,6 +31,13 @@ static void* return mem·arenaalloc(heap, n, size); } +static void* +·arenarealloc(void *heap, void *old, uint n, ulong size) +{ + /* does not free */ + return mem·arenaalloc(heap, n, size); +} + static void ·arenafree(void *heap, void *ptr) { @@ -38,8 +45,9 @@ static void } mem·Allocator mem·ArenaAllocator = { - .alloc = ·arenaalloc, - .free = ·arenafree, + .alloc = ·arenaalloc, + .realloc = ·arenarealloc, + .free = ·arenafree, }; diff --git a/src/base/mem/interface.c b/src/base/mem/interface.c index e128bb9..99cb774 100644 --- a/src/base/mem/interface.c +++ b/src/base/mem/interface.c @@ -20,12 +20,7 @@ static void * return realloc(ptr, n*size); } -mem·Allocator sys·Memory = { - .alloc = ·calloc, - .free = ·free -}; - -mem·Reallocator sys·FullMemory = { +mem·Allocator base·Memory = { .alloc = ·calloc, .realloc = ·realloc, .free = ·free -- cgit v1.2.1