diff -r 68ad5750ba6b -r 7960298039cf src/cx/allocator.h --- a/src/cx/allocator.h Sun Oct 03 10:43:31 2021 +0200 +++ b/src/cx/allocator.h Sun Oct 03 12:02:57 2021 +0200 @@ -64,7 +64,8 @@ * @param n the new size in bytes * @return a pointer to the re-allocated memory */ - void *(*realloc)(void *data, void *mem, size_t n); + void *(*realloc)(void *data, void *mem, size_t n) + __attribute__((__warn_unused_result__)); /** * Allocate \p nelem elements of \p n bytes each, all initialized to zero. @@ -84,7 +85,8 @@ * @param data the allocator's data * @param mem a pointer to the block to free */ - void (*free)(void *data, void *mem); + void (*free)(void *data, void *mem) + __attribute__((__nonnull__)); } cx_allocator_class; /** @@ -118,8 +120,8 @@ * @param n the number of bytes * @return a pointer to the allocated memory */ -__attribute__ ((malloc)) -void *cxMalloc(CxAllocator allocator, size_t n); +void *cxMalloc(CxAllocator allocator, size_t n) +__attribute__((__malloc__)); /** * Re-allocate the previously allocated block in \p mem, making the new block \p n bytes long. @@ -133,7 +135,8 @@ * @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)); /** * Re-allocate a previously allocated block and changes the pointer in-place, if necessary. @@ -150,8 +153,8 @@ * @param n the new size in bytes * @return zero on success, non-zero on failure */ -__attribute__ ((nonnull)) -int cxReallocate(CxAllocator allocator, void **mem, size_t n); +int cxReallocate(CxAllocator allocator, void **mem, size_t n) +__attribute__((nonnull)); /** * Allocate \p nelem elements of \p n bytes each, all initialized to zero. @@ -161,8 +164,8 @@ * @param n the size of each element in bytes * @return a pointer to the allocated memory */ -__attribute__ ((malloc)) -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n); +void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) +__attribute__((malloc)); /** * Free a block allocated by this allocator. @@ -172,8 +175,8 @@ * @param allocator the allocator * @param mem a pointer to the block to free */ -__attribute__((nonnull)) -void cxFree(CxAllocator allocator, void *mem); +void cxFree(CxAllocator allocator, void *mem) +__attribute__((nonnull)); #ifdef __cplusplus } /* extern "C" */