Sprinkling the source with static and attributes.
[tinc] / lib / avl_tree.c
index d35936e..53d82eb 100644 (file)
@@ -29,7 +29,7 @@
     library for inclusion into tinc (http://tinc.nl.linux.org/) by
     Guus Sliepen <guus@sliepen.eu.org>.
 
-    $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.14 2003/07/06 23:16:27 guus Exp $
 */
 
 #include <stdio.h>
@@ -53,7 +53,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 +91,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 +119,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 +521,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 +551,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)