MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_InsertItemInArray

Function cJSON_InsertItemInArray

framework/utils/cJSON.c:2141–2168  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

2139
2140/* Replace array/object items with new ones. */
2141CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
2142{
2143cJSON *after_inserted = NULL;
2144
2145if (which < 0)
2146{
2147return;
2148}
2149
2150after_inserted = get_array_item(array, (size_t)which);
2151if (after_inserted == NULL)
2152{
2153add_item_to_array(array, newitem);
2154return;
2155}
2156
2157newitem->next = after_inserted;
2158newitem->prev = after_inserted->prev;
2159after_inserted->prev = newitem;
2160if (after_inserted == array->child)
2161{
2162array->child = newitem;
2163}
2164else
2165{
2166newitem->prev->next = newitem;
2167}
2168}
2169
2170CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
2171{

Callers

nothing calls this directly

Calls 2

get_array_itemFunction · 0.85
add_item_to_arrayFunction · 0.85

Tested by

no test coverage detected