overwrite and existing item with another one and free resources on the way */
| 801 | |
| 802 | /* overwrite and existing item with another one and free resources on the way */ |
| 803 | static void overwrite_item(cJSON *const root, const cJSON replacement) |
| 804 | { |
| 805 | if (root == NULL) |
| 806 | { |
| 807 | return; |
| 808 | } |
| 809 | |
| 810 | if (root->string != NULL) |
| 811 | { |
| 812 | cJSON_free(root->string); |
| 813 | } |
| 814 | if (root->valuestring != NULL) |
| 815 | { |
| 816 | cJSON_free(root->valuestring); |
| 817 | } |
| 818 | if (root->child != NULL) |
| 819 | { |
| 820 | cJSON_Delete(root->child); |
| 821 | } |
| 822 | |
| 823 | memcpy(root, &replacement, sizeof(cJSON)); |
| 824 | } |
| 825 | |
| 826 | static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_sensitive) |
| 827 | { |
no test coverage detected