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

Function cJSON_ReplaceItemInArray

modules/freeswitch/esl/src/esl_json.c:524–526  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

522
523/* Replace array/object items with new ones. */
524ESL_DECLARE(void) cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
525 newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
526 if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
527ESL_DECLARE(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
528
529/* Create basic types: */

Callers 1

Calls 1

cJSON_DeleteFunction · 0.70

Tested by

no test coverage detected