diff -r 7b3a3130be44 -r 64ded9f6a6c6 ucx/cx/allocator.h --- a/ucx/cx/allocator.h Mon Jan 06 22:22:55 2025 +0100 +++ b/ucx/cx/allocator.h Tue Feb 25 21:11:00 2025 +0100 @@ -65,8 +65,8 @@ */ void *(*calloc)( void *data, - size_t nelem, - size_t n + size_t nmemb, + size_t size ); /** @@ -100,7 +100,8 @@ /** * A default allocator using standard library malloc() etc. */ -extern CxAllocator *cxDefaultAllocator; +cx_attr_export +extern const CxAllocator * const cxDefaultAllocator; /** * Function pointer type for destructor functions. @@ -131,7 +132,7 @@ ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * * @par Error handling @@ -145,13 +146,14 @@ */ cx_attr_nonnull cx_attr_nodiscard -int cx_reallocate( +cx_attr_export +int cx_reallocate_( void **mem, size_t n ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * * The size is calculated by multiplying @p nemb and @p size. @@ -169,14 +171,15 @@ */ cx_attr_nonnull cx_attr_nodiscard -int cx_reallocatearray( +cx_attr_export +int cx_reallocatearray_( void **mem, size_t nmemb, size_t size ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * * @par Error handling @@ -188,10 +191,10 @@ * @retval non-zero failure * @see cx_reallocatearray() */ -#define cx_reallocate(mem, n) cx_reallocate((void**)(mem), n) +#define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n) /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * * The size is calculated by multiplying @p nemb and @p size. @@ -207,7 +210,7 @@ * @retval non-zero failure */ #define cx_reallocatearray(mem, nmemb, size) \ - cx_reallocatearray((void**)(mem), nmemb, size) + cx_reallocatearray_((void**)(mem), nmemb, size) /** * Free a block allocated by this allocator. @@ -218,6 +221,7 @@ * @param mem a pointer to the block to free */ cx_attr_nonnull_arg(1) +cx_attr_export void cxFree( const CxAllocator *allocator, void *mem @@ -235,13 +239,14 @@ cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2) +cx_attr_export void *cxMalloc( const CxAllocator *allocator, size_t n ); /** - * Re-allocate the previously allocated block in @p mem, making the new block + * Reallocate the previously allocated block in @p mem, making the new block * @p n bytes long. * This function may return the same pointer that was passed to it, if moving * the memory was not necessary. @@ -251,12 +256,13 @@ * @param allocator the allocator * @param mem pointer to the previously allocated block * @param n the new size in bytes - * @return a pointer to the re-allocated memory + * @return a pointer to the reallocated memory */ cx_attr_nodiscard cx_attr_nonnull_arg(1) cx_attr_dealloc_ucx cx_attr_allocsize(3) +cx_attr_export void *cxRealloc( const CxAllocator *allocator, void *mem, @@ -264,7 +270,7 @@ ); /** - * Re-allocate the previously allocated block in @p mem, making the new block + * Reallocate the previously allocated block in @p mem, making the new block * @p n bytes long. * This function may return the same pointer that was passed to it, if moving * the memory was not necessary. @@ -279,12 +285,13 @@ * @param mem pointer to the previously allocated block * @param nmemb the number of elements * @param size the size of each element - * @return a pointer to the re-allocated memory + * @return a pointer to the reallocated memory */ cx_attr_nodiscard cx_attr_nonnull_arg(1) cx_attr_dealloc_ucx cx_attr_allocsize(3, 4) +cx_attr_export void *cxReallocArray( const CxAllocator *allocator, void *mem, @@ -293,7 +300,7 @@ ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * This function acts like cxRealloc() using the pointer pointed to by @p mem. * @@ -310,14 +317,15 @@ */ cx_attr_nodiscard cx_attr_nonnull -int cxReallocate( +cx_attr_export +int cxReallocate_( const CxAllocator *allocator, void **mem, size_t n ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * This function acts like cxRealloc() using the pointer pointed to by @p mem. * @@ -333,10 +341,10 @@ * @retval non-zero failure */ #define cxReallocate(allocator, mem, n) \ - cxReallocate(allocator, (void**)(mem), n) + cxReallocate_(allocator, (void**)(mem), n) /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * This function acts like cxReallocArray() using the pointer pointed to * by @p mem. @@ -356,7 +364,8 @@ */ cx_attr_nodiscard cx_attr_nonnull -int cxReallocateArray( +cx_attr_export +int cxReallocateArray_( const CxAllocator *allocator, void **mem, size_t nmemb, @@ -364,7 +373,7 @@ ); /** - * Re-allocate a previously allocated block and changes the pointer in-place, + * Reallocate a previously allocated block and changes the pointer in-place, * if necessary. * This function acts like cxReallocArray() using the pointer pointed to * by @p mem. @@ -383,14 +392,14 @@ * @retval non-zero failure */ #define cxReallocateArray(allocator, mem, nmemb, size) \ - cxReallocateArray(allocator, (void**) (mem), nmemb, size) + cxReallocateArray_(allocator, (void**) (mem), nmemb, size) /** - * Allocate @p nelem elements of @p n bytes each, all initialized to zero. + * Allocate @p nmemb elements of @p n bytes each, all initialized to zero. * * @param allocator the allocator - * @param nelem the number of elements - * @param n the size of each element in bytes + * @param nmemb the number of elements + * @param size the size of each element in bytes * @return a pointer to the allocated memory */ cx_attr_nonnull_arg(1) @@ -398,10 +407,11 @@ cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2, 3) +cx_attr_export void *cxCalloc( const CxAllocator *allocator, - size_t nelem, - size_t n + size_t nmemb, + size_t size ); #ifdef __cplusplus