| 2267 | |
| 2268 | /* Replace array/object items with new ones. */ |
| 2269 | CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2270 | { |
| 2271 | cJSON *after_inserted = NULL; |
| 2272 | |
| 2273 | if (which < 0) |
| 2274 | { |
| 2275 | return false; |
| 2276 | } |
| 2277 | |
| 2278 | after_inserted = get_array_item(array, (size_t)which); |
| 2279 | if (after_inserted == NULL) |
| 2280 | { |
| 2281 | return add_item_to_array(array, newitem); |
| 2282 | } |
| 2283 | |
| 2284 | newitem->next = after_inserted; |
| 2285 | newitem->prev = after_inserted->prev; |
| 2286 | after_inserted->prev = newitem; |
| 2287 | if (after_inserted == array->child) |
| 2288 | { |
| 2289 | array->child = newitem; |
| 2290 | } |
| 2291 | else |
| 2292 | { |
| 2293 | newitem->prev->next = newitem; |
| 2294 | } |
| 2295 | return true; |
| 2296 | } |
| 2297 | |
| 2298 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) |
| 2299 | { |
nothing calls this directly
no test coverage detected