diff -r 0f4aa9fc75d9 -r 81a4c3a63e65 src/allocator.c --- a/src/allocator.c Sun Feb 14 15:37:12 2021 +0100 +++ b/src/allocator.c Mon Mar 01 22:19:06 2021 +0100 @@ -29,6 +29,7 @@ #include "cx/allocator.h" #include +#include void *cx_malloc_stdlib(void *unused, size_t n) { return malloc(n); @@ -67,6 +68,20 @@ return allocator->cl->realloc(allocator->data, mem, n); } +int cxReallocate(CxAllocator allocator, void **mem, size_t n) { + if (mem == NULL) { + errno = EINVAL; + return 1; + } + void* nmem = allocator->cl->realloc(allocator->data, *mem, n); + if (nmem == NULL) { + return 1; + } else { + *mem = nmem; + return 0; + } +} + void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { return allocator->cl->calloc(allocator->data, nelem, n); }