cJSONUtils_PatchDetach -> detach_path

This commit is contained in:
Max Bruckner 2017-04-30 14:36:21 +02:00
parent 7f645de322
commit aefe2f85ab

View File

@ -356,7 +356,8 @@ static cJSON *detach_item_from_array(cJSON *array, size_t which)
return c; return c;
} }
static cJSON *cJSONUtils_PatchDetach(cJSON *object, const unsigned char *path) /* detach an item at the given path */
static cJSON *detach_path(cJSON *object, const unsigned char *path)
{ {
unsigned char *parent_pointer = NULL; unsigned char *parent_pointer = NULL;
unsigned char *child_pointer = NULL; unsigned char *child_pointer = NULL;
@ -685,7 +686,7 @@ static int cJSONUtils_ApplyPatch(cJSON *object, const cJSON *patch)
if ((opcode == REMOVE) || (opcode == REPLACE)) if ((opcode == REMOVE) || (opcode == REPLACE))
{ {
/* Get rid of old. */ /* Get rid of old. */
cJSON *old_item = cJSONUtils_PatchDetach(object, (unsigned char*)path->valuestring); cJSON *old_item = detach_path(object, (unsigned char*)path->valuestring);
if (old_item == NULL) if (old_item == NULL)
{ {
status = 13; status = 13;
@ -713,7 +714,7 @@ static int cJSONUtils_ApplyPatch(cJSON *object, const cJSON *patch)
if (opcode == MOVE) if (opcode == MOVE)
{ {
value = cJSONUtils_PatchDetach(object, (unsigned char*)from->valuestring); value = detach_path(object, (unsigned char*)from->valuestring);
} }
if (opcode == COPY) if (opcode == COPY)
{ {