Replace array/object items with new ones. */
| 2147 | |
| 2148 | /* Replace array/object items with new ones. */ |
| 2149 | CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2150 | { |
| 2151 | cJSON *after_inserted = NULL; |
| 2152 | |
| 2153 | if (which < 0) |
| 2154 | { |
| 2155 | return; |
| 2156 | } |
| 2157 | |
| 2158 | after_inserted = get_array_item(array, (size_t)which); |
| 2159 | if (after_inserted == NULL) |
| 2160 | { |
| 2161 | add_item_to_array(array, newitem); |
| 2162 | return; |
| 2163 | } |
| 2164 | |
| 2165 | newitem->next = after_inserted; |
| 2166 | newitem->prev = after_inserted->prev; |
| 2167 | after_inserted->prev = newitem; |
| 2168 | if (after_inserted == array->child) |
| 2169 | { |
| 2170 | array->child = newitem; |
| 2171 | } |
| 2172 | else |
| 2173 | { |
| 2174 | newitem->prev->next = newitem; |
| 2175 | } |
| 2176 | } |
| 2177 | |
| 2178 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) |
| 2179 | { |
nothing calls this directly
no test coverage detected