src/json.c

changeset 1601
e47078681a6f
parent 1600
a1a728d7ebfd
child 1602
7329821fd768
--- a/src/json.c	Sun Dec 14 14:29:27 2025 +0100
+++ b/src/json.c	Sun Dec 14 15:41:02 2025 +0100
@@ -410,7 +410,7 @@
             size_t capa = str.length + 32;
             char *space = cxMallocDefault(capa);
             if (space == NULL) return cx_mutstrn(NULL, 0);
-            cxBufferInit(&buf, space, capa, NULL, CX_BUFFER_AUTO_EXTEND);
+            cxBufferInit(&buf, NULL, space, capa, CX_BUFFER_AUTO_EXTEND);
             cxBufferWrite(str.ptr, 1, i, &buf);
             all_printable = false;
         }
@@ -575,8 +575,8 @@
         // reinitialize the buffer
         cxBufferDestroy(&json->buffer);
         if (buf == NULL) buf = ""; // buffer must not be initialized with NULL
-        cxBufferInit(&json->buffer, (char*) buf, size,
-            NULL, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_COPY_ON_WRITE);
+        cxBufferInit(&json->buffer, NULL, (char*) buf,
+                     size, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_COPY_ON_WRITE);
         json->buffer.size = size;
         return 0;
     } else {
@@ -1424,8 +1424,8 @@
 static cxmutstr cx_json_to_string(CxJsonValue *value, const CxAllocator *allocator, CxJsonWriter *writer) {
     if (allocator == NULL) allocator = cxDefaultAllocator;
     CxBuffer buffer;
-    if (cxBufferInit(&buffer, NULL, 128, allocator,
-        CX_BUFFER_AUTO_EXTEND | CX_BUFFER_DO_NOT_FREE)) {
+    if (cxBufferInit(&buffer, allocator, NULL, 128,
+                     CX_BUFFER_AUTO_EXTEND | CX_BUFFER_DO_NOT_FREE)) {
         return (cxmutstr){NULL, 0};
     }
     if (cx_json_write_rec(&buffer, value, cxBufferWriteFunc, writer, 0)

mercurial