MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / replace_item_in_object

Function replace_item_in_object

external/cJSON/cJSON.c:2427–2448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2425}
2426
2427static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
2428{
2429 if ((replacement == NULL) || (string == NULL))
2430 {
2431 return false;
2432 }
2433
2434 /* replace the name in the replacement */
2435 if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
2436 {
2437 cJSON_free(replacement->string);
2438 }
2439 replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
2440 if (replacement->string == NULL)
2441 {
2442 return false;
2443 }
2444
2445 replacement->type &= ~cJSON_StringIsConst;
2446
2447 return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
2448}
2449
2450CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2451{

Calls 4

cJSON_freeFunction · 0.85
cJSON_strdupFunction · 0.85
get_object_itemFunction · 0.85

Tested by

no test coverage detected