src/json.c

changeset 1675
36c0fb2b60b2
parent 1672
94360453bce4
equal deleted inserted replaced
1674:8b0f162ac88e 1675:36c0fb2b60b2
1497 CxJsonValue* cxJsonClone(const CxJsonValue* value, const CxAllocator* allocator) { 1497 CxJsonValue* cxJsonClone(const CxJsonValue* value, const CxAllocator* allocator) {
1498 return cx_json_clone_func(NULL, value, allocator, NULL); 1498 return cx_json_clone_func(NULL, value, allocator, NULL);
1499 } 1499 }
1500 1500
1501 CxJsonValue* cx_json_clone_func(CxJsonValue* target, const CxJsonValue* source, 1501 CxJsonValue* cx_json_clone_func(CxJsonValue* target, const CxJsonValue* source,
1502 const CxAllocator* allocator, cx_attr_unused void *data) { 1502 const CxAllocator* allocator, CX_UNUSED void *data) {
1503 if (source == NULL || source->type == CX_JSON_NOTHING) { 1503 if (source == NULL || source->type == CX_JSON_NOTHING) {
1504 return &cx_json_value_nothing; 1504 return &cx_json_value_nothing;
1505 } 1505 }
1506 if (allocator == NULL) allocator = cxDefaultAllocator; 1506 if (allocator == NULL) allocator = cxDefaultAllocator;
1507 1507
1509 CxJsonValue *ret = v; \ 1509 CxJsonValue *ret = v; \
1510 if (target == NULL) { \ 1510 if (target == NULL) { \
1511 return ret; \ 1511 return ret; \
1512 } else { \ 1512 } else { \
1513 *target = *ret; \ 1513 *target = *ret; \
1514 cxFree(allocator, ret); \ 1514 ret->type = CX_JSON_UNINITIALIZED; \
1515 cxJsonValueFree(ret); \
1515 return target; \ 1516 return target; \
1516 } \ 1517 } \
1517 } 1518 }
1518 1519
1519 switch (source->type) { 1520 switch (source->type) {

mercurial