MCPcopy Create free account
hub / github.com/Netis/cloud-probe / overwrite_item

Function overwrite_item

cpworker/src/cJSON/cJSON_Utils.c:803–824  ·  view source on GitHub ↗

overwrite and existing item with another one and free resources on the way */

Source from the content-addressed store, hash-verified

801
802/* overwrite and existing item with another one and free resources on the way */
803static 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
826static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_sensitive)
827{

Callers 1

apply_patchFunction · 0.85

Calls 2

cJSON_freeFunction · 0.85
cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected