Sun, 07 Dec 2025 13:17:25 +0100
improve member names of CxJsonArray
| src/cx/json.h | file | annotate | diff | comparison | revisions | |
| src/json.c | file | annotate | diff | comparison | revisions |
--- a/src/cx/json.h Sat Dec 06 18:13:28 2025 +0100 +++ b/src/cx/json.h Sun Dec 07 13:17:25 2025 +0100 @@ -217,7 +217,7 @@ /** * The array data. */ - CX_ARRAY_DECLARE(CxJsonValue*, array); + CX_ARRAY_DECLARE(CxJsonValue*, data); }; /** @@ -1181,7 +1181,7 @@ */ cx_attr_nonnull CX_INLINE size_t cxJsonArrSize(const CxJsonValue *value) { - return value->array.array_size; + return value->array.data_size; } /**
--- a/src/json.c Sat Dec 06 18:13:28 2025 +0100 +++ b/src/json.c Sun Dec 07 13:17:25 2025 +0100 @@ -470,8 +470,8 @@ v->type = type; v->allocator = json->allocator; if (type == CX_JSON_ARRAY) { - cx_array_initialize_a(json->allocator, v->array.array, 16); - if (v->array.array == NULL) goto create_json_value_exit_error; // LCOV_EXCL_LINE + cx_array_initialize_a(json->allocator, v->array.data, 16); + if (v->array.data == NULL) goto create_json_value_exit_error; // LCOV_EXCL_LINE } else if (type == CX_JSON_OBJECT) { v->object = json_create_object_map(json->allocator); if (v->object == NULL) goto create_json_value_exit_error; // LCOV_EXCL_LINE @@ -483,7 +483,7 @@ assert(parent != NULL); if (parent->type == CX_JSON_ARRAY) { CxArrayReallocator value_realloc = cx_array_reallocator(json->allocator, NULL); - if (cx_array_simple_add_a(&value_realloc, parent->array.array, v)) { + if (cx_array_simple_add_a(&value_realloc, parent->array.data, v)) { goto create_json_value_exit_error; // LCOV_EXCL_LINE } } else if (parent->type == CX_JSON_OBJECT) { @@ -799,10 +799,10 @@ } case CX_JSON_ARRAY: { CxJsonArray array = value->array; - for (size_t i = 0; i < array.array_size; i++) { - cxJsonValueFree(array.array[i]); + for (size_t i = 0; i < array.data_size; i++) { + cxJsonValueFree(array.data[i]); } - cxFree(value->allocator, array.array); + cxFree(value->allocator, array.data); break; } case CX_JSON_STRING: { @@ -837,8 +837,8 @@ if (v == NULL) return NULL; v->allocator = allocator; v->type = CX_JSON_ARRAY; - cx_array_initialize_a(allocator, v->array.array, 16); - if (v->array.array == NULL) { cxFree(allocator, v); return NULL; } + cx_array_initialize_a(allocator, v->array.data, 16); + if (v->array.data == NULL) { cxFree(allocator, v); return NULL; } return v; } @@ -959,8 +959,8 @@ CxArrayReallocator value_realloc = cx_array_reallocator(arr->allocator, NULL); assert(arr->type == CX_JSON_ARRAY); return cx_array_simple_copy_a(&value_realloc, - arr->array.array, - arr->array.array_size, + arr->array.data, + arr->array.data_size, val, count ); } @@ -1012,23 +1012,23 @@ } CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index) { - if (index >= value->array.array_size) { + if (index >= value->array.data_size) { return &cx_json_value_nothing; } - return value->array.array[index]; + return value->array.data[index]; } CxJsonValue *cxJsonArrRemove(CxJsonValue *value, size_t index) { - if (index >= value->array.array_size) { + if (index >= value->array.data_size) { return NULL; } - CxJsonValue *ret = value->array.array[index]; + CxJsonValue *ret = value->array.data[index]; // TODO: replace with a low level cx_array_remove() - size_t count = value->array.array_size - index - 1; + size_t count = value->array.data_size - index - 1; if (count > 0) { - memmove(value->array.array + index, value->array.array + index + 1, count * sizeof(CxJsonValue*)); + memmove(value->array.data + index, value->array.data + index + 1, count * sizeof(CxJsonValue*)); } - value->array.array_size--; + value->array.data_size--; return ret; } @@ -1062,8 +1062,8 @@ CxIterator cxJsonArrIter(const CxJsonValue *value) { return cxIteratorPtr( - value->array.array, - value->array.array_size, + value->array.data, + value->array.data_size, true // arrays need to keep order ); }