# HG changeset patch # User Mike Becker # Date 1729340666 -7200 # Node ID 312fb24c14de9c164a73f89fbebd8bec877566e9 # Parent a43ed636d1ffe03b6919cbc6076b43f615fffeec add convenience macro for cx_reallocate to hide the (void**) cast diff -r a43ed636d1ff -r 312fb24c14de src/allocator.c --- a/src/allocator.c Sat Oct 19 13:49:44 2024 +0200 +++ b/src/allocator.c Sat Oct 19 14:24:26 2024 +0200 @@ -75,7 +75,7 @@ }; CxAllocator *cxDefaultAllocator = &cx_default_allocator; - +#undef cx_reallocate int cx_reallocate( void **mem, size_t n diff -r a43ed636d1ff -r 312fb24c14de src/cx/allocator.h --- a/src/cx/allocator.h Sat Oct 19 13:49:44 2024 +0200 +++ b/src/cx/allocator.h Sat Oct 19 14:24:26 2024 +0200 @@ -151,6 +151,18 @@ ); /** + * Re-allocate a previously allocated block and changes the pointer in-place, if necessary. + * + * \par Error handling + * \c errno will be set by realloc() on failure. + * + * @param mem pointer to the pointer to allocated block + * @param n the new size in bytes + * @return zero on success, non-zero on failure + */ +#define cx_reallocate(mem, n) cx_reallocate((void**)(mem), n) + +/** * Allocate \p n bytes of memory. * * @param allocator the allocator