X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Favl_tree.c;h=a8477aa46e149ad15d99eb3b331879f883fa0261;hp=caaba3ed6905471e8307ff359e94915456066c8b;hb=5260cf0b5649fc25b9d69a97f9604a3be257e13e;hpb=54d3007554444024077d89091d63e4a250fedd01 diff --git a/src/avl_tree.c b/src/avl_tree.c index caaba3ed..a8477aa4 100644 --- a/src/avl_tree.c +++ b/src/avl_tree.c @@ -7,11 +7,15 @@ * Author: Eric Biggers * Year: 2014 * - * This file is placed into the public domain. You can do whatever you want - * with it. + * The author dedicates this file to the public domain. + * You can do whatever you want with this file. */ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "wimlib/avl_tree.h" /* Starts an in-order traversal of the tree: returns the least-valued node, or * NULL if the tree is empty. */ @@ -127,15 +131,6 @@ avl_get_balance_factor(const struct avl_tree_node *node) return (int)(node->parent_balance & 3) - 1; } -/* Sets the balance factor of the specified AVL tree node. This must be - * -1, 0, or 1. */ -static AVL_INLINE void -avl_set_balance_factor(struct avl_tree_node *node, int balance_factor) -{ - node->parent_balance = - (node->parent_balance & ~3) | (balance_factor + 1); -} - /* Adds @amount to the balance factor of the specified AVL tree node. * The caller must ensure this still results in a valid balance factor * (-1, 0, or 1). */ @@ -380,12 +375,10 @@ avl_handle_subtree_growth(struct avl_tree_node ** const root_ptr, */ avl_rotate(root_ptr, parent, -sign); - /* Equivalent to: - * avl_set_balance_factor(parent, 0); */ + /* Equivalent to setting @parent's balance factor to 0. */ avl_adjust_balance_factor(parent, -sign); /* A */ - /* Equivalent to: - * avl_set_balance_factor(node, 0); */ + /* Equivalent to setting @node's balance factor to 0. */ avl_adjust_balance_factor(node, -sign); /* B */ } else { /* @node (B below) is heavy in the direction opposite