42 void* cx_malloc_stdlib(cx_allocator a, size_t n); |
42 void* cx_malloc_stdlib(cx_allocator a, size_t n); |
43 void* cx_realloc_stdlib(cx_allocator a, void* mem, size_t n); |
43 void* cx_realloc_stdlib(cx_allocator a, void* mem, size_t n); |
44 void* cx_calloc_stdlib(cx_allocator a, size_t nelem, size_t n); |
44 void* cx_calloc_stdlib(cx_allocator a, size_t nelem, size_t n); |
45 void cx_free_stdlib(cx_allocator a, void* mem); |
45 void cx_free_stdlib(cx_allocator a, void* mem); |
46 |
46 |
47 struct cx_allocator_class { |
47 typedef struct { |
48 cx_malloc_func malloc; |
48 cx_malloc_func malloc; |
49 cx_realloc_func realloc; |
49 cx_realloc_func realloc; |
50 cx_calloc_func calloc; |
50 cx_calloc_func calloc; |
51 cx_free_func free; |
51 cx_free_func free; |
52 }; |
52 } cx_allocator_class; |
|
53 |
|
54 extern cx_allocator_class cx_default_allocator_class; |
53 |
55 |
54 /* HIGH LEVEL API */ |
56 /* HIGH LEVEL API */ |
55 |
57 |
56 struct cx_allocator_s { |
58 struct cx_allocator_s { |
57 struct cx_allocator_class allocatorClass; |
59 cx_allocator_class *cl; |
58 void* data; |
60 cx_allocator data; |
59 }; |
61 }; |
60 typedef struct cx_allocator_s* CxAllocator; |
62 typedef struct cx_allocator_s* CxAllocator; |
61 |
63 |
62 extern CxAllocator cxDefaultAllocator; |
64 extern CxAllocator cxDefaultAllocator; |
63 |
65 |