src/allocator.c

changeset 394
80c31ebd66c1
parent 391
f094a53c1178
child 396
3539dd99ab92
     1.1 --- a/src/allocator.c	Sun Feb 07 15:35:52 2021 +0100
     1.2 +++ b/src/allocator.c	Sun Feb 07 16:24:41 2021 +0100
     1.3 @@ -31,10 +31,12 @@
     1.4  #include <stdlib.h>
     1.5  
     1.6  struct cx_allocator_s cx_default_allocator = {
     1.7 -        cx_malloc_stdlib,
     1.8 -        cx_realloc_stdlib,
     1.9 -        cx_calloc_stdlib,
    1.10 -        cx_free_stdlib,
    1.11 +        {
    1.12 +            cx_malloc_stdlib,
    1.13 +            cx_realloc_stdlib,
    1.14 +            cx_calloc_stdlib,
    1.15 +            cx_free_stdlib
    1.16 +        },
    1.17          NULL
    1.18  };
    1.19  CxAllocator cxDefaultAllocator = &cx_default_allocator;
    1.20 @@ -54,3 +56,19 @@
    1.21  void cx_free_stdlib(cx_allocator a, void* mem) {
    1.22      free(mem);
    1.23  }
    1.24 +
    1.25 +void* cxMalloc(CxAllocator allocator, size_t n) {
    1.26 +    return allocator->allocatorClass.malloc(allocator, n);
    1.27 +}
    1.28 +
    1.29 +void* cxRealloc(CxAllocator allocator, void* mem, size_t n) {
    1.30 +    return allocator->allocatorClass.realloc(allocator, mem, n);
    1.31 +}
    1.32 +
    1.33 +void* cxCalloc(CxAllocator allocator, size_t nelem, size_t n) {
    1.34 +    return allocator->allocatorClass.calloc(allocator, nelem, n);
    1.35 +}
    1.36 +
    1.37 +void cxFree(CxAllocator allocator, void* mem) {
    1.38 +    allocator->allocatorClass.free(allocator, mem);
    1.39 +}
    1.40 \ No newline at end of file

mercurial