src/cx/string.h

changeset 1667
608cc0b25352
parent 1652
db8299984bfe
child 1668
3ffdfe1776b4
--- a/src/cx/string.h	Wed Dec 24 12:13:59 2025 +0100
+++ b/src/cx/string.h	Thu Dec 25 11:10:13 2025 +0100
@@ -416,9 +416,6 @@
  * If @p str already contains a string, the memory will be reallocated and
  * the other strings are appended. Otherwise, new memory is allocated.
  *
- * If memory allocation fails, the pointer in the returned string will
- * be @c NULL. Depending on the allocator, @c errno might be set.
- *
  * @note It is guaranteed that there is only one allocation for the
  * resulting string.
  * It is also guaranteed that the returned string is zero-terminated.
@@ -427,32 +424,12 @@
  * @param str   the string the other strings shall be concatenated to
  * @param count the number of the other following strings to concatenate
  * @param ...   all other UCX strings
- * @return the concatenated string
+ * @retval zero success
+ * @retval non-zero allocation failure
  */
-cx_attr_nodiscard cx_attr_nonnull
-CX_EXPORT cxmutstr cx_strcat_ma(const CxAllocator *alloc,
-        cxmutstr str, size_t count, ...);
-
-/**
- * Concatenates strings and returns a new string.
- *
- * The resulting string will be allocated by the specified allocator.
- * So developers @em must pass the return value to cx_strfree_a() eventually.
- *
-* If memory allocation fails, the pointer in the returned string will
- * be @c NULL. Depending on the allocator, @c errno might be set.
- *
- * @note It is guaranteed that there is only one allocation for the
- * resulting string.
- * It is also guaranteed that the returned string is zero-terminated.
- *
- * @param alloc (@c CxAllocator*) the allocator to use
- * @param count (@c size_t) the number of the other following strings to concatenate
- * @param ...   all other UCX strings
- * @return (@c cxmutstr) the concatenated string
- */
-#define cx_strcat_a(alloc, count, ...) \
-        cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
+cx_attr_nonnull
+CX_EXPORT int cx_strcat_a(const CxAllocator *alloc,
+        cxmutstr *str, size_t count, ...);
 
 /**
  * Concatenates strings and returns a new string.
@@ -460,43 +437,18 @@
  * The resulting string will be allocated by the cxDefaultAllocator.
  * So developers @em must pass the return value to cx_strfree() eventually.
  *
-* If memory allocation fails, the pointer in the returned string will
- * be @c NULL and @c errno might be set.
- *
  * @note It is guaranteed that there is only one allocation for the
  * resulting string.
  * It is also guaranteed that the returned string is zero-terminated.
  *
+ * @param str (@c cxmutstr*) the string the other strings shall be concatenated to
  * @param count (@c size_t) the number of the other following strings to concatenate
  * @param ... all other UCX strings
- * @return (@c cxmutstr) the concatenated string
+ * @retval zero success
+ * @retval non-zero allocation failure
  */
-#define cx_strcat(count, ...) \
-        cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
-
-/**
- * Concatenates strings.
- *
- * The resulting string will be allocated by the cxDefaultAllocator.
- * So developers @em must pass the return value to cx_strfree() eventually.
- *
- * If @p str already contains a string, the memory will be reallocated and
- * the other strings are appended. Otherwise, new memory is allocated.
- *
-* If memory allocation fails, the pointer in the returned string will
- * be @c NULL and @c errno might be set.
- *
- * @note It is guaranteed that there is only one allocation for the
- * resulting string.
- * It is also guaranteed that the returned string is zero-terminated.
- *
- * @param str (@c cxmutstr) the string the other strings shall be concatenated to
- * @param count (@c size_t) the number of the other following strings to concatenate
- * @param ... all other strings
- * @return (@c cxmutstr) the concatenated string
- */
-#define cx_strcat_m(str, count, ...) \
-        cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__)
+#define cx_strcat(str, count, ...) \
+        cx_strcat_a(cxDefaultAllocator, str, count, __VA_ARGS__)
 
 /**
  * Returns a substring starting at the specified location.

mercurial