summaryrefslogtreecommitdiffstats
path: root/src/dfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dfs.c')
-rw-r--r--src/dfs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dfs.c b/src/dfs.c
index b0bda53..12f4ee2 100644
--- a/src/dfs.c
+++ b/src/dfs.c
@@ -92,11 +92,12 @@ struct online_return dfs_online(struct data * data, struct front_item * front, s
front_last->next = new_front_item(tree->values.p, tree->values.w, front_last, NULL);
front_last = front_last->next;
+ /* Adjust prev and next */
+ if(tree->prev != NULL) tree->prev->next = tree->next;
+ if(tree->next != NULL) tree->next->prev = tree->prev;
+
struct tree_item * old = tree;
tree = tree->next;
- if(tree != NULL) {
- tree->prev = old->prev;
- }
free(old);
change++;
@@ -125,6 +126,10 @@ struct online_return dfs_online(struct data * data, struct front_item * front, s
/* Update left next */
left->next = right;
+ /* Adjust prev and next */
+ if(tree->prev != NULL) tree->prev->next = left;
+ if(tree->next != NULL) tree->next->prev = right;
+
/* Update tree to left node and free old node */
struct tree_item * old = tree;
tree = left;