overwrite and existing item with another one and free resources on the way */
| 782 | |
| 783 | /* overwrite and existing item with another one and free resources on the way */ |
| 784 | static void overwrite_item(cJSON * const root, const cJSON replacement) |
| 785 | { |
| 786 | if (root == NULL) |
| 787 | { |
| 788 | return; |
| 789 | } |
| 790 | |
| 791 | if (root->string != NULL) |
| 792 | { |
| 793 | cJSON_free(root->string); |
| 794 | } |
| 795 | if (root->valuestring != NULL) |
| 796 | { |
| 797 | cJSON_free(root->valuestring); |
| 798 | } |
| 799 | if (root->child != NULL) |
| 800 | { |
| 801 | cJSON_Delete(root->child); |
| 802 | } |
| 803 | |
| 804 | memcpy(root, &replacement, sizeof(cJSON)); |
| 805 | } |
| 806 | |
| 807 | static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_sensitive) |
| 808 | { |
no test coverage detected
searching dependent graphs…