MCPcopy Create free account
hub / github.com/SVF-tools/SVF / cJSON_InsertItemInArray

Function cJSON_InsertItemInArray

svf/lib/Util/cJSON.cpp:2269–2296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2267
2268/* Replace array/object items with new ones. */
2269CJSON_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
2298CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
2299{

Callers

nothing calls this directly

Calls 2

get_array_itemFunction · 0.85
add_item_to_arrayFunction · 0.85

Tested by

no test coverage detected