MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / cJSON_ReplaceItemInArray

Function cJSON_ReplaceItemInArray

outofcore/src/cJSON.cpp:537–539  ·  view source on GitHub ↗

Replace array/object items with new ones. */

Source from the content-addressed store, hash-verified

535
536/* Replace array/object items with new ones. */
537void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
538 newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
539 if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=nullptr;cJSON_Delete(c);}
540void 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);}}
541
542/* Create basic types: */

Callers 1

Calls 1

cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected