From 8f6d296a23675687177afd697cb28d195252466e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 8 May 2024 12:32:10 +0200 Subject: Add a heap allocator --- lib/alloc/heapalloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/alloc/heapalloc.c (limited to 'lib/alloc') diff --git a/lib/alloc/heapalloc.c b/lib/alloc/heapalloc.c new file mode 100644 index 0000000..0a698f0 --- /dev/null +++ b/lib/alloc/heapalloc.c @@ -0,0 +1,12 @@ +#include + +#include "alloc.h" + +void * +heapalloc(void *, void *ptr, size_t, size_t new) +{ + if (new > 0) + return realloc(ptr, new); + free(ptr); + return nullptr; +} -- cgit v1.2.3