1.1 --- a/src/allocator.c Sun Feb 07 16:52:21 2021 +0100 1.2 +++ b/src/allocator.c Sun Feb 07 17:17:46 2021 +0100 1.3 @@ -30,13 +30,15 @@ 1.4 1.5 #include <stdlib.h> 1.6 1.7 +cx_allocator_class cx_default_allocator_class = { 1.8 + cx_malloc_stdlib, 1.9 + cx_realloc_stdlib, 1.10 + cx_calloc_stdlib, 1.11 + cx_free_stdlib 1.12 +}; 1.13 + 1.14 struct cx_allocator_s cx_default_allocator = { 1.15 - { 1.16 - cx_malloc_stdlib, 1.17 - cx_realloc_stdlib, 1.18 - cx_calloc_stdlib, 1.19 - cx_free_stdlib 1.20 - }, 1.21 + &cx_default_allocator_class, 1.22 NULL 1.23 }; 1.24 CxAllocator cxDefaultAllocator = &cx_default_allocator; 1.25 @@ -58,17 +60,17 @@ 1.26 } 1.27 1.28 void* cxMalloc(CxAllocator allocator, size_t n) { 1.29 - return allocator->allocatorClass.malloc(allocator, n); 1.30 + return allocator->cl->malloc(allocator->data, n); 1.31 } 1.32 1.33 void* cxRealloc(CxAllocator allocator, void* mem, size_t n) { 1.34 - return allocator->allocatorClass.realloc(allocator, mem, n); 1.35 + return allocator->cl->realloc(allocator->data, mem, n); 1.36 } 1.37 1.38 void* cxCalloc(CxAllocator allocator, size_t nelem, size_t n) { 1.39 - return allocator->allocatorClass.calloc(allocator, nelem, n); 1.40 + return allocator->cl->calloc(allocator->data, nelem, n); 1.41 } 1.42 1.43 void cxFree(CxAllocator allocator, void* mem) { 1.44 - allocator->allocatorClass.free(allocator, mem); 1.45 + allocator->cl->free(allocator->data, mem); 1.46 } 1.47 \ No newline at end of file