Replace array/object items with new ones. */
| 2257 | |
| 2258 | /* Replace array/object items with new ones. */ |
| 2259 | CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2260 | { |
| 2261 | cJSON *after_inserted = NULL; |
| 2262 | |
| 2263 | if (which < 0) |
| 2264 | { |
| 2265 | return false; |
| 2266 | } |
| 2267 | |
| 2268 | after_inserted = get_array_item(array, (size_t)which); |
| 2269 | if (after_inserted == NULL) |
| 2270 | { |
| 2271 | return add_item_to_array(array, newitem); |
| 2272 | } |
| 2273 | |
| 2274 | newitem->next = after_inserted; |
| 2275 | newitem->prev = after_inserted->prev; |
| 2276 | after_inserted->prev = newitem; |
| 2277 | if (after_inserted == array->child) |
| 2278 | { |
| 2279 | array->child = newitem; |
| 2280 | } |
| 2281 | else |
| 2282 | { |
| 2283 | newitem->prev->next = newitem; |
| 2284 | } |
| 2285 | return true; |
| 2286 | } |
| 2287 | |
| 2288 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) |
| 2289 | { |
nothing calls this directly
no test coverage detected