MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / cJSON_ReplaceItemInArray

Function cJSON_ReplaceItemInArray

common/map_sdk/transmission/src/cJSON.cpp:747–761  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

745
746/* Replace array/object items with new ones. */
747void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) {
748 cJSON *c = array->child;
749 while (c && which > 0) c = c->next, which--;
750 if (!c) return;
751 newitem->next = c->next;
752 newitem->prev = c->prev;
753 if (newitem->next) newitem->next->prev = newitem;
754 if (c == array->child) {
755 array->child = newitem;
756 } else {
757 newitem->prev->next = newitem;
758 }
759 c->next = c->prev = 0;
760 cJSON_Delete(c);
761}
762void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) {
763 int i = 0;
764 cJSON *c = object->child;

Callers 2

ReplaceMethod · 0.85

Calls 1

cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected