X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Favl_tree.c;h=65df7b79f946a0e5c7a07631714b6187cb8467a0;hp=d35936e6804043fef08481e5e1c3f3902f87904b;hb=5cb147135184e3748c6f5e6e6203d22ab9f904f8;hpb=161f917dd03c174742fb8c6722f430a93b506cb1 diff --git a/lib/avl_tree.c b/lib/avl_tree.c index d35936e6..65df7b79 100644 --- a/lib/avl_tree.c +++ b/lib/avl_tree.c @@ -1,9 +1,9 @@ /* avl_tree.c -- avl_ tree and linked list convenience Copyright (C) 1998 Michael H. Buselli - 2000,2001 Ivo Timmermans , - 2000,2001 Guus Sliepen - 2000,2001 Wessel Dankers + 2000-2003 Ivo Timmermans , + 2000-2003 Guus Sliepen + 2000-2003 Wessel Dankers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,14 +29,13 @@ library for inclusion into tinc (http://tinc.nl.linux.org/) by Guus Sliepen . - $Id: avl_tree.c,v 1.1.2.12 2002/09/10 09:40:15 guus Exp $ + $Id: avl_tree.c,v 1.1.2.16 2003/07/17 15:06:25 guus Exp $ */ -#include -#include -#include +#include "system.h" #include "avl_tree.h" +#include "xalloc.h" #ifdef AVL_COUNT #define AVL_NODE_COUNT(n) ((n) ? (n)->count : 0) @@ -53,7 +52,9 @@ #endif #ifndef AVL_DEPTH -int lg(unsigned int u) +static int lg(unsigned int u) __attribute__ ((const)); + +static int lg(unsigned int u) { int r = 1; @@ -89,7 +90,7 @@ int lg(unsigned int u) /* Internal helper functions */ -int avl_check_balance(avl_node_t *node) +static int avl_check_balance(avl_node_t *node) { #ifdef AVL_DEPTH int d; @@ -117,7 +118,7 @@ int avl_check_balance(avl_node_t *node) #endif } -void avl_rebalance(avl_tree_t *tree, avl_node_t *node) +static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) { avl_node_t *child; avl_node_t *gchild; @@ -519,7 +520,7 @@ void avl_insert_before(avl_tree_t *tree, avl_node_t *before, before->prev = node; before->left = node; - avl_rebalance(tree, before->parent); + avl_rebalance(tree, before); } void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node) @@ -549,7 +550,7 @@ void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node) after->next = node; after->right = node; - avl_rebalance(tree, after->parent); + avl_rebalance(tree, after); } avl_node_t *avl_unlink(avl_tree_t *tree, void *data)