MCPcopy Create free account
hub / github.com/Bwar/CJsonObject / cJSON_ReplaceItemInArray

Function cJSON_ReplaceItemInArray

cJSON.c:936–953  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

934
935/* Replace array/object items with new ones. */
936void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
937{
938 cJSON *c = array->child;
939 while (c && which > 0)
940 c = c->next, which--;
941 if (!c)
942 return;
943 newitem->next = c->next;
944 newitem->prev = c->prev;
945 if (newitem->next)
946 newitem->next->prev = newitem;
947 if (c == array->child)
948 array->child = newitem;
949 else
950 newitem->prev->next = newitem;
951 c->next = c->prev = 0;
952 cJSON_Delete(c);
953}
954void cJSON_ReplaceItemInObject(cJSON *object, const char *string,
955 cJSON *newitem)
956{

Callers 4

ReplaceMethod · 0.85
ReplaceWithMoveMethod · 0.85
ReplaceWithNullMethod · 0.85

Calls 1

cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected