X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fbt.c;h=4178d1475af769810a3f193d3af3d1afb5c48797;hb=81579d9e9f994fb2908f50af41c3eb033d216e58;hp=26eb982b25d47c26c9699c24018a0910cb2dbcd5;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/libpspp/bt.c b/src/libpspp/bt.c index 26eb982b..4178d147 100644 --- a/src/libpspp/bt.c +++ b/src/libpspp/bt.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc. 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 @@ -61,12 +61,14 @@ #include #endif -#include +#include "libpspp/bt.h" #include #include #include +#include "libpspp/cast.h" + static void rebalance_subtree (struct bt *, struct bt_node *, size_t); static struct bt_node **down_link (struct bt *, struct bt_node *); @@ -79,9 +81,7 @@ static inline int calculate_h_alpha (size_t); /* Initializes BT as an empty BT that uses the given COMPARE function, passing in AUX as auxiliary data. */ void -bt_init (struct bt *bt, - bt_compare_func *compare, - const void *aux) +bt_init (struct bt *bt, bt_compare_func *compare, const void *aux) { bt->root = NULL; bt->compare = compare; @@ -250,7 +250,7 @@ bt_find (const struct bt *bt, const struct bt_node *target) { cmp = bt->compare (target, p, bt->aux); if (cmp == 0) - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } return NULL; @@ -283,7 +283,7 @@ bt_find_ge (const struct bt *bt, const struct bt_node *target) break; } } - return (struct bt_node *) q; + return CONST_CAST (struct bt_node *, q); } /* Searches BT for, and returns, the last node in in-order whose @@ -314,7 +314,7 @@ bt_find_le (const struct bt *bt, const struct bt_node *target) break; } } - return (struct bt_node *) q; + return CONST_CAST (struct bt_node *, q); } /* Returns the node in BT following P in in-order. @@ -338,7 +338,7 @@ bt_next (const struct bt *bt, const struct bt_node *p) p = p->down[1]; while (p->down[0] != NULL) p = p->down[0]; - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } } @@ -363,7 +363,7 @@ bt_prev (const struct bt *bt, const struct bt_node *p) p = p->down[0]; while (p->down[1] != NULL) p = p->down[1]; - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } }