src/string.c

changeset 1304
57e062a4bb05
parent 1300
fcb149ee60ff
--- a/src/string.c	Sat Apr 19 11:36:53 2025 +0200
+++ b/src/string.c	Sat Apr 19 14:43:16 2025 +0200
@@ -80,6 +80,22 @@
     str->length = 0;
 }
 
+int cx_strcpy_a(
+        const CxAllocator *alloc,
+        cxmutstr *dest,
+        cxstring src
+) {
+    if (cxReallocate(alloc, &dest->ptr, src.length + 1)) {
+        return 1;
+    }
+
+    memcpy(dest->ptr, src.ptr, src.length);
+    dest->length = src.length;
+    dest->ptr[dest->length] = '\0';
+
+    return 0;
+}
+
 size_t cx_strlen(
         size_t count,
         ...

mercurial