| 2425 | } |
| 2426 | |
| 2427 | static 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 | |
| 2450 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) |
| 2451 | { |
no test coverage detected