From 0b0c2a372ff5d11f73af172e07a93b2656374a42 Mon Sep 17 00:00:00 2001 From: Wessel Dankers Date: Tue, 20 Feb 2001 21:53:18 +0000 Subject: [PATCH] Important bugfix in avl_insert_before() and avl_insert_after() --- lib/avl_tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/avl_tree.c b/lib/avl_tree.c index 8630d4d0..9b7a06c1 100644 --- a/lib/avl_tree.c +++ b/lib/avl_tree.c @@ -29,7 +29,7 @@ library for inclusion into tinc (http://tinc.nl.linux.org/) by Guus Sliepen . - $Id: avl_tree.c,v 1.1.2.5 2001/02/06 10:13:21 guus Exp $ + $Id: avl_tree.c,v 1.1.2.6 2001/02/20 21:53:18 wsl Exp $ */ #include @@ -493,6 +493,9 @@ void avl_insert_before(avl_tree_t *tree, avl_node_t *before, avl_node_t *node) node->parent = before; node->prev = before->prev; + if(before->left) + return avl_insert_after(tree, before->prev, node); + if (before->prev) before->prev->next = node; else @@ -509,6 +512,9 @@ void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node) if (!after) return tree->head ? avl_insert_before(tree, tree->head, node) : avl_insert_top(tree, node); + if(after->right) + return avl_insert_before(tree, after->next, node); + node->prev = after; node->parent = after; node->next = after->next; -- 2.20.1