1.1 --- a/src/allocator.c Sun Feb 07 17:17:46 2021 +0100 1.2 +++ b/src/allocator.c Sun Feb 07 18:08:21 2021 +0100 1.3 @@ -30,6 +30,22 @@ 1.4 1.5 #include <stdlib.h> 1.6 1.7 +void *cx_malloc_stdlib(void *unused, size_t n) { 1.8 + return malloc(n); 1.9 +} 1.10 + 1.11 +void *cx_realloc_stdlib(void *unused, void *mem, size_t n) { 1.12 + return realloc(mem, n); 1.13 +} 1.14 + 1.15 +void *cx_calloc_stdlib(void *unused, size_t nelem, size_t n) { 1.16 + return calloc(nelem, n); 1.17 +} 1.18 + 1.19 +void cx_free_stdlib(void *unused, void *mem) { 1.20 + free(mem); 1.21 +} 1.22 + 1.23 cx_allocator_class cx_default_allocator_class = { 1.24 cx_malloc_stdlib, 1.25 cx_realloc_stdlib, 1.26 @@ -43,34 +59,18 @@ 1.27 }; 1.28 CxAllocator cxDefaultAllocator = &cx_default_allocator; 1.29 1.30 -void* cx_malloc_stdlib(cx_allocator a, size_t n) { 1.31 - return malloc(n); 1.32 -} 1.33 - 1.34 -void* cx_realloc_stdlib(cx_allocator a, void* mem, size_t n) { 1.35 - return realloc(mem, n); 1.36 -} 1.37 - 1.38 -void* cx_calloc_stdlib(cx_allocator a, size_t nelem, size_t n) { 1.39 - return calloc(nelem, n); 1.40 -} 1.41 - 1.42 -void cx_free_stdlib(cx_allocator a, void* mem) { 1.43 - free(mem); 1.44 -} 1.45 - 1.46 -void* cxMalloc(CxAllocator allocator, size_t n) { 1.47 +void *cxMalloc(CxAllocator allocator, size_t n) { 1.48 return allocator->cl->malloc(allocator->data, n); 1.49 } 1.50 1.51 -void* cxRealloc(CxAllocator allocator, void* mem, size_t n) { 1.52 +void *cxRealloc(CxAllocator allocator, void *mem, size_t n) { 1.53 return allocator->cl->realloc(allocator->data, mem, n); 1.54 } 1.55 1.56 -void* cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { 1.57 +void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { 1.58 return allocator->cl->calloc(allocator->data, nelem, n); 1.59 } 1.60 1.61 -void cxFree(CxAllocator allocator, void* mem) { 1.62 +void cxFree(CxAllocator allocator, void *mem) { 1.63 allocator->cl->free(allocator->data, mem); 1.64 -} 1.65 \ No newline at end of file 1.66 +}