MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cJSON_InsertItemInArray

Function cJSON_InsertItemInArray

lib/cJSON.c:2024–2048  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

2022
2023/* Replace array/object items with new ones. */
2024void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
2025{
2026 cJSON *c = array->child;
2027 while (c && (which > 0))
2028 {
2029 c = c->next;
2030 which--;
2031 }
2032 if (!c)
2033 {
2034 cJSON_AddItemToArray(array, newitem);
2035 return;
2036 }
2037 newitem->next = c;
2038 newitem->prev = c->prev;
2039 c->prev = newitem;
2040 if (c == array->child)
2041 {
2042 array->child = newitem;
2043 }
2044 else
2045 {
2046 newitem->prev->next = newitem;
2047 }
2048}
2049
2050static void ReplaceItemInArray(cJSON *array, size_t which, cJSON *newitem)
2051{

Callers

nothing calls this directly

Calls 1

cJSON_AddItemToArrayFunction · 0.70

Tested by

no test coverage detected