diff -r cf19b7820ff0 -r 94360453bce4 docs/Writerside/topics/string.h.md --- a/docs/Writerside/topics/string.h.md Thu Dec 25 12:07:37 2025 +0100 +++ b/docs/Writerside/topics/string.h.md Sun Dec 28 14:10:14 2025 +0100 @@ -49,6 +49,7 @@ void cx_strfree_a(const CxAllocator *alloc, cxmutstr *str); +#define CX_NULLSTR cx_mutstr(NULL) #define CX_SFMT(s) (int) (s).length, (s).ptr #define CX_PRIstr ".*s" #define cx_strcast(s) // converts any string to cxstring @@ -119,23 +120,26 @@ ```C #include -int cx_strcat(cxmutstr *str, size_t count, ... ); +cxmutstr cx_strcat(cxmutstr str, size_t count, ... ); -int cx_strcat_a(const CxAllocator *allocator, - cxmutstr *str, size_t count, ... ); +cxmutstr cx_strcat_a(const CxAllocator *allocator, + cxmutstr str, size_t count, ... ); size_t cx_strlen(size_t count, ...); ``` The `cx_strcat_a()` function takes `count` UCX strings (`cxstring` or `cxmutstr` - not pointers!), -allocates memory in `str` for a concatenation of those strings _with a single allocation_, +reallocates the memory in `str` for a concatenation of those strings _with a single allocation_, and appends the contents of the strings to `str`. `cx_strcat()` is equivalent, except that it uses the [default allocator](allocator.h.md#default-allocator). +When there is no `str` where the other strings shall be appended to, you can pass `CX_NULLSTR` as first argument. +In that case, a completely new string is allocated. + Example usage: ```C -cxmutstr str = {0}; -cx_strcat(&str, 2, cx_str("Hello, "), cx_str("World!")); +cxmutstr str = cx_strcat(CX_NULLSTR, 2, + cx_str("Hello, "), cx_str("World!")); ``` The function `cx_strlen()` sums the length of the specified strings.