| 451 cxBufferDestroy(&buf); |
451 cxBufferDestroy(&buf); |
| 452 return ret; |
452 return ret; |
| 453 } |
453 } |
| 454 |
454 |
| 455 static CxJsonObject json_create_object_map(const CxAllocator *allocator) { |
455 static CxJsonObject json_create_object_map(const CxAllocator *allocator) { |
| 456 CxMap *map = cxKvListCreateAsMap(allocator, NULL, CX_STORE_POINTERS); |
456 CxMap *map = cxKvListCreateAsMap(allocator, (cx_compare_func) cxJsonCompare, CX_STORE_POINTERS); |
| 457 if (map == NULL) return NULL; // LCOV_EXCL_LINE |
457 if (map == NULL) return NULL; // LCOV_EXCL_LINE |
| 458 // TODO: fix the specification of the compare function |
458 // TODO: fix the specification of the compare function |
| 459 map->collection.cmpfunc = (cx_compare_func) cxJsonCompare; |
459 map->collection.cmpfunc = (cx_compare_func) cxJsonCompare; |
| 460 cxDefineDestructor(map, cxJsonValueFree); |
460 cxDefineDestructor(map, cxJsonValueFree); |
| 461 return map; |
461 return map; |
| 1500 CxJsonValue* cx_json_clone_func(CxJsonValue* target, const CxJsonValue* source, |
1500 CxJsonValue* cx_json_clone_func(CxJsonValue* target, const CxJsonValue* source, |
| 1501 const CxAllocator* allocator, cx_attr_unused void *data) { |
1501 const CxAllocator* allocator, cx_attr_unused void *data) { |
| 1502 if (source == NULL || source->type == CX_JSON_NOTHING) { |
1502 if (source == NULL || source->type == CX_JSON_NOTHING) { |
| 1503 return &cx_json_value_nothing; |
1503 return &cx_json_value_nothing; |
| 1504 } |
1504 } |
| |
1505 if (allocator == NULL) allocator = cxDefaultAllocator; |
| 1505 |
1506 |
| 1506 #define return_value(v) { \ |
1507 #define return_value(v) { \ |
| 1507 CxJsonValue *ret = v; \ |
1508 CxJsonValue *ret = v; \ |
| 1508 if (target == NULL) { \ |
1509 if (target == NULL) { \ |
| 1509 return ret; \ |
1510 return ret; \ |
| 1522 // LCOV_EXCL_START |
1523 // LCOV_EXCL_START |
| 1523 cxJsonValueFree(obj); |
1524 cxJsonValueFree(obj); |
| 1524 return NULL; |
1525 return NULL; |
| 1525 // LCOV_EXCL_STOP |
1526 // LCOV_EXCL_STOP |
| 1526 } |
1527 } |
| 1527 return obj; |
1528 return_value(obj); |
| 1528 } |
1529 } |
| 1529 case CX_JSON_ARRAY: { |
1530 case CX_JSON_ARRAY: { |
| 1530 const size_t elem_count = source->array.data_size; |
1531 const size_t elem_count = source->array.data_size; |
| 1531 CxArrayReallocator reallocator = cx_array_reallocator(allocator, NULL); |
1532 CxArrayReallocator reallocator = cx_array_reallocator(allocator, NULL); |
| 1532 CxJsonValue *arr = cxJsonCreateArr(allocator); |
1533 CxJsonValue *arr = cxJsonCreateArr(allocator); |
| 1546 return NULL; |
1547 return NULL; |
| 1547 // LCOV_EXCL_STOP |
1548 // LCOV_EXCL_STOP |
| 1548 } |
1549 } |
| 1549 arr->array.data[i] = e; |
1550 arr->array.data[i] = e; |
| 1550 } |
1551 } |
| 1551 return arr; |
1552 return_value(arr); |
| 1552 } |
1553 } |
| 1553 case CX_JSON_STRING: |
1554 case CX_JSON_STRING: |
| 1554 return_value(cxJsonCreateString(allocator, source->string)); |
1555 return_value(cxJsonCreateString(allocator, source->string)); |
| 1555 case CX_JSON_INTEGER: |
1556 case CX_JSON_INTEGER: |
| 1556 return_value(cxJsonCreateInteger(allocator, source->integer)); |
1557 return_value(cxJsonCreateInteger(allocator, source->integer)); |