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

Function cJSON_ReplaceItemInObject

lib/cJSON.c:2089–2109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2087}
2088
2089void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2090{
2091 size_t i = 0;
2092 cJSON *c = object->child;
2093 while(c && cJSON_strcasecmp((unsigned char*)c->string, (const unsigned char*)string))
2094 {
2095 i++;
2096 c = c->next;
2097 }
2098 if(c)
2099 {
2100 /* free the old string if not const */
2101 if (!(newitem->type & cJSON_StringIsConst) && newitem->string)
2102 {
2103 cJSON_free(newitem->string);
2104 }
2105
2106 newitem->string = (char*)cJSON_strdup((const unsigned char*)string);
2107 ReplaceItemInArray(object, i, newitem);
2108 }
2109}
2110
2111/* Create basic types: */
2112cJSON *cJSON_CreateNull(void)

Callers

nothing calls this directly

Calls 3

ReplaceItemInArrayFunction · 0.85
cJSON_strcasecmpFunction · 0.70
cJSON_strdupFunction · 0.70

Tested by

no test coverage detected