diff -r 3539dd99ab92 -r cfc1193b1e65 src/allocator.c --- a/src/allocator.c Sun Feb 07 17:17:46 2021 +0100 +++ b/src/allocator.c Sun Feb 07 18:08:21 2021 +0100 @@ -30,6 +30,22 @@ #include +void *cx_malloc_stdlib(void *unused, size_t n) { + return malloc(n); +} + +void *cx_realloc_stdlib(void *unused, void *mem, size_t n) { + return realloc(mem, n); +} + +void *cx_calloc_stdlib(void *unused, size_t nelem, size_t n) { + return calloc(nelem, n); +} + +void cx_free_stdlib(void *unused, void *mem) { + free(mem); +} + cx_allocator_class cx_default_allocator_class = { cx_malloc_stdlib, cx_realloc_stdlib, @@ -43,34 +59,18 @@ }; CxAllocator cxDefaultAllocator = &cx_default_allocator; -void* cx_malloc_stdlib(cx_allocator a, size_t n) { - return malloc(n); -} - -void* cx_realloc_stdlib(cx_allocator a, void* mem, size_t n) { - return realloc(mem, n); -} - -void* cx_calloc_stdlib(cx_allocator a, size_t nelem, size_t n) { - return calloc(nelem, n); -} - -void cx_free_stdlib(cx_allocator a, void* mem) { - free(mem); -} - -void* cxMalloc(CxAllocator allocator, size_t n) { +void *cxMalloc(CxAllocator allocator, size_t n) { return allocator->cl->malloc(allocator->data, n); } -void* cxRealloc(CxAllocator allocator, void* mem, size_t n) { +void *cxRealloc(CxAllocator allocator, void *mem, size_t n) { return allocator->cl->realloc(allocator->data, mem, n); } -void* cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { +void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { return allocator->cl->calloc(allocator->data, nelem, n); } -void cxFree(CxAllocator allocator, void* mem) { +void cxFree(CxAllocator allocator, void *mem) { allocator->cl->free(allocator->data, mem); -} \ No newline at end of file +}