--- a/docs/Writerside/topics/allocator.h.md Fri May 23 14:00:24 2025 +0200 +++ b/docs/Writerside/topics/allocator.h.md Sat May 24 00:04:11 2025 +0200 @@ -23,6 +23,8 @@ void *cxMalloc(const CxAllocator *allocator, size_t n); +void *cxZalloc(const CxAllocator *allocator, size_t n); + void *cxCalloc(const CxAllocator *allocator, size_t nmemb, size_t size); @@ -38,7 +40,9 @@ void cxFree(const CxAllocator *allocator, void *mem); -int cx_reallocate(void **mem, size_t size); +void *cx_zalloc(size_t n); + +int cx_reallocate(void **mem, size_t n); int cx_reallocatearray(void **mem, size_t nmemb, size_t size); @@ -50,6 +54,7 @@ // Convenience macros that invokes above functions with the cxDefaultAllocator. #define cxMallocDefault(...) +#define cxZallocDefault(...) #define cxCallocDefault(...) #define cxReallocDefault(...) #define cxReallocateDefault(...) @@ -75,6 +80,9 @@ most prominently that invocations of `cxFree()` with a `NULL`-pointer for `mem` are ignored instead of causing segfault error. +The functions `cxZalloc()` and `cx_zalloc()` allocate memory and set every allocated byte to zero. +The latter is merely a macro for stdlibc `calloc(1,n)`. + Additionally, UCX provides the functions `cxReallocate()` and `cxReallocateArray()`, as well as their independent pendants `cx_reallocate()` and `cx_reallocatearray()`. All those functions solve the problem that a possible reallocation might fail,