src/json.c

changeset 1600
a1a728d7ebfd
parent 1596
2d2c4ec38133
child 1601
e47078681a6f
--- a/src/json.c	Sun Dec 14 14:15:26 2025 +0100
+++ b/src/json.c	Sun Dec 14 14:29:27 2025 +0100
@@ -453,7 +453,7 @@
 }
 
 static CxJsonObject json_create_object_map(const CxAllocator *allocator) {
-    CxMap *map = cxKvListCreateAsMap(allocator, NULL, CX_STORE_POINTERS);
+    CxMap *map = cxKvListCreateAsMap(allocator, (cx_compare_func) cxJsonCompare, CX_STORE_POINTERS);
     if (map == NULL) return NULL; // LCOV_EXCL_LINE
     // TODO: fix the specification of the compare function
     map->collection.cmpfunc = (cx_compare_func) cxJsonCompare;
@@ -1502,6 +1502,7 @@
     if (source == NULL || source->type == CX_JSON_NOTHING) {
         return &cx_json_value_nothing;
     }
+    if (allocator == NULL) allocator = cxDefaultAllocator;
 
 #define return_value(v) { \
         CxJsonValue *ret = v; \
@@ -1524,7 +1525,7 @@
                 return NULL;
                 // LCOV_EXCL_STOP
             }
-            return obj;
+            return_value(obj);
         }
         case CX_JSON_ARRAY: {
             const size_t elem_count = source->array.data_size;
@@ -1548,7 +1549,7 @@
                 }
                 arr->array.data[i] = e;
             }
-            return arr;
+            return_value(arr);
         }
         case CX_JSON_STRING:
             return_value(cxJsonCreateString(allocator, source->string));

mercurial