diff -r 3dc9075df822 -r eb9e7bd40a8e src/cx/allocator.h --- a/src/cx/allocator.h Sat Jan 29 14:32:04 2022 +0100 +++ b/src/cx/allocator.h Sun Jan 30 14:19:00 2022 +0100 @@ -83,12 +83,12 @@ /** * High-Level type alias for the allocator type. */ -typedef struct cx_allocator_s *CxAllocator; +typedef struct cx_allocator_s CxAllocator; /** * A default allocator using standard library malloc() etc. */ -extern CxAllocator cxDefaultAllocator; +extern CxAllocator *cxDefaultAllocator; /** * Allocate \p n bytes of memory. @@ -97,7 +97,10 @@ * @param n the number of bytes * @return a pointer to the allocated memory */ -void *cxMalloc(CxAllocator allocator, size_t n) +void *cxMalloc( + CxAllocator *allocator, + size_t n +) __attribute__((__malloc__)) __attribute__((__alloc_size__(2))); @@ -113,7 +116,11 @@ * @param n the new size in bytes * @return a pointer to the re-allocated memory */ -void *cxRealloc(CxAllocator allocator, void *mem, size_t n) +void *cxRealloc( + CxAllocator *allocator, + void *mem, + size_t n +) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(3))); @@ -132,7 +139,11 @@ * @param n the new size in bytes * @return zero on success, non-zero on failure */ -int cxReallocate(CxAllocator allocator, void **mem, size_t n) +int cxReallocate( + CxAllocator *allocator, + void **mem, + size_t n +) __attribute__((__nonnull__)); /** @@ -143,7 +154,11 @@ * @param n the size of each element in bytes * @return a pointer to the allocated memory */ -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) +void *cxCalloc( + CxAllocator *allocator, + size_t nelem, + size_t n +) __attribute__((__malloc__)) __attribute__((__alloc_size__(2, 3))); @@ -155,7 +170,10 @@ * @param allocator the allocator * @param mem a pointer to the block to free */ -void cxFree(CxAllocator allocator, void *mem) +void cxFree( + CxAllocator *allocator, + void *mem +) __attribute__((__nonnull__)); #ifdef __cplusplus