summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/internal.h8
-rw-r--r--src/object.c10
2 files changed, 8 insertions, 10 deletions
diff --git a/src/internal.h b/src/internal.h
index 7ea8a5e..f1e08dc 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -56,14 +56,6 @@ inline static void add_children(struct json *dest, struct json *src) {
src->parent = dest;
}
-inline static void adjust_pointers(struct json* from, struct json* to) {
- to->prev = from->prev;
- to->next = from->next;
- if (from->prev) from->prev->next = to;
- if (from->next) from->next->prev = to;
-}
-
-
enum json_parse_result parse_value(struct json **json_out, struct raw_json *raw, size_t depth);
enum json_parse_result parse_object(struct json **json_out, struct raw_json *raw, size_t depth);
enum json_parse_result parse_array(struct json **json_out, struct raw_json *raw, size_t depth);
diff --git a/src/object.c b/src/object.c
index b380008..7178bdd 100644
--- a/src/object.c
+++ b/src/object.c
@@ -27,9 +27,15 @@ void add_to_object(struct json *dest, char *key, struct json *src) {
if (strcmp(e->key, key) == 0) {
src->index = e->index;
dest->children->items[i] = src;
+ src->parent = dest;
- adjust_pointers(e, src);
- json_delete(e);
+ src->prev = e->prev;
+ src->next = e->next;
+ if (e->prev) e->prev->next = src;
+ if (e->next) e->next->prev = src;
+
+ json_clear(e);
+ free(e);
return;
}
}