X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Favl_tree.c;h=0d122bf6919fad8d78084e32c62a96b91167cc0b;hp=4b237560423f379b72507960eed1bb7ccef50628;hb=ba25e899d0f13f84a0300240b8f67df818dcafa6;hpb=e913f3f232e4809b7218d081ab9f94cef1c94ac3 diff --git a/src/avl_tree.c b/src/avl_tree.c index 4b237560..0d122bf6 100644 --- a/src/avl_tree.c +++ b/src/avl_tree.c @@ -2,7 +2,7 @@ avl_tree.c -- avl_ tree and linked list convenience Copyright (C) 1998 Michael H. Buselli 2000-2005 Ivo Timmermans, - 2000-2006 Guus Sliepen + 2000-2015 Guus Sliepen 2000-2005 Wessel Dankers This program is free software; you can redistribute it and/or modify @@ -26,7 +26,7 @@ the code. Mail me if you found a bug. Cleaned up and incorporated some of the ideas from the red-black tree - library for inclusion into tinc (http://www.tinc-vpn.org/) by + library for inclusion into tinc (https://www.tinc-vpn.org/) by Guus Sliepen . */ @@ -123,8 +123,6 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) avl_node_t *parent; avl_node_t **superparent; - parent = node; - while(node) { parent = node->parent; @@ -168,14 +166,12 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) child->right->parent = child; gchild->right = node; - if(gchild->right) - gchild->right->parent = gchild; + gchild->right->parent = gchild; gchild->left = child; - if(gchild->left) - gchild->left->parent = gchild; - *superparent = gchild; + gchild->left->parent = gchild; + *superparent = gchild; gchild->parent = parent; #ifdef AVL_COUNT node->count = AVL_CALC_COUNT(node); @@ -224,8 +220,7 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) child->left->parent = child; gchild->left = node; - if(gchild->left) - gchild->left->parent = gchild; + gchild->left->parent = gchild; gchild->right = child; gchild->right->parent = gchild;