diff options
Diffstat (limited to 'src/dfs.c')
-rw-r--r-- | src/dfs.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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; |