MCPcopy Create free account
hub / github.com/antirez/botlib / replace_item_in_object

Function replace_item_in_object

cJSON.c:2347–2363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2345}
2346
2347static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
2348{
2349 if ((replacement == NULL) || (string == NULL))
2350 {
2351 return false;
2352 }
2353
2354 /* replace the name in the replacement */
2355 if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
2356 {
2357 cJSON_free(replacement->string);
2358 }
2359 replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
2360 replacement->type &= ~cJSON_StringIsConst;
2361
2362 return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
2363}
2364
2365CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2366{

Calls 4

cJSON_freeFunction · 0.85
cJSON_strdupFunction · 0.85
get_object_itemFunction · 0.85

Tested by

no test coverage detected