Replace array/object items with new ones. */
| 2022 | |
| 2023 | /* Replace array/object items with new ones. */ |
| 2024 | void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2025 | { |
| 2026 | cJSON *c = array->child; |
| 2027 | while (c && (which > 0)) |
| 2028 | { |
| 2029 | c = c->next; |
| 2030 | which--; |
| 2031 | } |
| 2032 | if (!c) |
| 2033 | { |
| 2034 | cJSON_AddItemToArray(array, newitem); |
| 2035 | return; |
| 2036 | } |
| 2037 | newitem->next = c; |
| 2038 | newitem->prev = c->prev; |
| 2039 | c->prev = newitem; |
| 2040 | if (c == array->child) |
| 2041 | { |
| 2042 | array->child = newitem; |
| 2043 | } |
| 2044 | else |
| 2045 | { |
| 2046 | newitem->prev->next = newitem; |
| 2047 | } |
| 2048 | } |
| 2049 | |
| 2050 | static void ReplaceItemInArray(cJSON *array, size_t which, cJSON *newitem) |
| 2051 | { |
nothing calls this directly
no test coverage detected