From: Wessel Dankers Date: Tue, 20 Feb 2001 21:53:18 +0000 (+0000) Subject: Important bugfix in avl_insert_before() and avl_insert_after() X-Git-Tag: release-1.0pre4~39 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0b0c2a372ff5d11f73af172e07a93b2656374a42;p=oweals%2Ftinc.git Important bugfix in avl_insert_before() and avl_insert_after() --- diff --git a/lib/avl_tree.c b/lib/avl_tree.c index 8630d4d..9b7a06c 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;