| 2221 | } |
| 2222 | |
| 2223 | static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) |
| 2224 | { |
| 2225 | if ((replacement == NULL) || (string == NULL)) |
| 2226 | { |
| 2227 | return false; |
| 2228 | } |
| 2229 | |
| 2230 | /* replace the name in the replacement */ |
| 2231 | if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) |
| 2232 | { |
| 2233 | cJSON_free(replacement->string); |
| 2234 | } |
| 2235 | replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); |
| 2236 | replacement->type &= ~cJSON_StringIsConst; |
| 2237 | |
| 2238 | cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); |
| 2239 | |
| 2240 | return true; |
| 2241 | } |
| 2242 | |
| 2243 | CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) |
| 2244 | { |
no test coverage detected