| 2410 | } |
| 2411 | |
| 2412 | static 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 | |
| 2435 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) |
| 2436 | { |
no test coverage detected
searching dependent graphs…