MCPcopy Create free account
hub / github.com/DaveGamble/cJSON / replace_item_in_object

Function replace_item_in_object

cJSON.c:2412–2433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2410}
2411
2412static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
2413{
2414 if ((replacement == NULL) || (string == NULL))
2415 {
2416 return false;
2417 }
2418
2419 /* replace the name in the replacement */
2420 if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
2421 {
2422 cJSON_free(replacement->string);
2423 }
2424 replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
2425 if (replacement->string == NULL)
2426 {
2427 return false;
2428 }
2429
2430 replacement->type &= ~cJSON_StringIsConst;
2431
2432 return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
2433}
2434
2435CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2436{

Calls 4

cJSON_freeFunction · 0.85
cJSON_strdupFunction · 0.85
get_object_itemFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…