1.1 --- a/src/cx/allocator.h Sun Oct 03 10:43:31 2021 +0200 1.2 +++ b/src/cx/allocator.h Sun Oct 03 12:02:57 2021 +0200 1.3 @@ -64,7 +64,8 @@ 1.4 * @param n the new size in bytes 1.5 * @return a pointer to the re-allocated memory 1.6 */ 1.7 - void *(*realloc)(void *data, void *mem, size_t n); 1.8 + void *(*realloc)(void *data, void *mem, size_t n) 1.9 + __attribute__((__warn_unused_result__)); 1.10 1.11 /** 1.12 * Allocate \p nelem elements of \p n bytes each, all initialized to zero. 1.13 @@ -84,7 +85,8 @@ 1.14 * @param data the allocator's data 1.15 * @param mem a pointer to the block to free 1.16 */ 1.17 - void (*free)(void *data, void *mem); 1.18 + void (*free)(void *data, void *mem) 1.19 + __attribute__((__nonnull__)); 1.20 } cx_allocator_class; 1.21 1.22 /** 1.23 @@ -118,8 +120,8 @@ 1.24 * @param n the number of bytes 1.25 * @return a pointer to the allocated memory 1.26 */ 1.27 -__attribute__ ((malloc)) 1.28 -void *cxMalloc(CxAllocator allocator, size_t n); 1.29 +void *cxMalloc(CxAllocator allocator, size_t n) 1.30 +__attribute__((__malloc__)); 1.31 1.32 /** 1.33 * Re-allocate the previously allocated block in \p mem, making the new block \p n bytes long. 1.34 @@ -133,7 +135,8 @@ 1.35 * @param n the new size in bytes 1.36 * @return a pointer to the re-allocated memory 1.37 */ 1.38 -void *cxRealloc(CxAllocator allocator, void *mem, size_t n); 1.39 +void *cxRealloc(CxAllocator allocator, void *mem, size_t n) 1.40 +__attribute__((warn_unused_result)); 1.41 1.42 /** 1.43 * Re-allocate a previously allocated block and changes the pointer in-place, if necessary. 1.44 @@ -150,8 +153,8 @@ 1.45 * @param n the new size in bytes 1.46 * @return zero on success, non-zero on failure 1.47 */ 1.48 -__attribute__ ((nonnull)) 1.49 -int cxReallocate(CxAllocator allocator, void **mem, size_t n); 1.50 +int cxReallocate(CxAllocator allocator, void **mem, size_t n) 1.51 +__attribute__((nonnull)); 1.52 1.53 /** 1.54 * Allocate \p nelem elements of \p n bytes each, all initialized to zero. 1.55 @@ -161,8 +164,8 @@ 1.56 * @param n the size of each element in bytes 1.57 * @return a pointer to the allocated memory 1.58 */ 1.59 -__attribute__ ((malloc)) 1.60 -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n); 1.61 +void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) 1.62 +__attribute__((malloc)); 1.63 1.64 /** 1.65 * Free a block allocated by this allocator. 1.66 @@ -172,8 +175,8 @@ 1.67 * @param allocator the allocator 1.68 * @param mem a pointer to the block to free 1.69 */ 1.70 -__attribute__((nonnull)) 1.71 -void cxFree(CxAllocator allocator, void *mem); 1.72 +void cxFree(CxAllocator allocator, void *mem) 1.73 +__attribute__((nonnull)); 1.74 1.75 #ifdef __cplusplus 1.76 } /* extern "C" */