MCPcopy Create free account
hub / github.com/armink/struct2json / cJSON_InsertItemInArray

Function cJSON_InsertItemInArray

struct2json/src/cJSON.c:696–697  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

694
695/* Replace array/object items with new ones. */
696void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;}
697 newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;}
698void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
699 newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
700 if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}

Callers

nothing calls this directly

Calls 1

cJSON_AddItemToArrayFunction · 0.85

Tested by

no test coverage detected