X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fabt.c;h=b776612922f2579b290f3a3657f12adb8efee0fe;hb=20ab4257de9330d8ad358fd8f66ebcd75bd1846a;hp=53e66f5118f677516b9bb358bfa6acc026f762d2;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp diff --git a/src/libpspp/abt.c b/src/libpspp/abt.c index 53e66f5118..b776612922 100644 --- a/src/libpspp/abt.c +++ b/src/libpspp/abt.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 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 @@ -29,6 +29,7 @@ #endif #include +#include #include @@ -118,7 +119,7 @@ abt_insert (struct abt *abt, struct abt_node *node) the tree, if AFTER is true, or the last node, if AFTER is false. */ static inline void -insert_relative (struct abt *abt, struct abt_node *p, bool after, +insert_relative (struct abt *abt, const struct abt_node *p, bool after, struct abt_node *node) { node->down[0] = NULL; @@ -145,8 +146,8 @@ insert_relative (struct abt *abt, struct abt_node *p, bool after, p = p->down[dir]; dir = !after; } - p->down[dir] = node; - node->up = p; + CONST_CAST (struct abt_node *, p)->down[dir] = node; + node->up = CONST_CAST (struct abt_node *, p); abt_reaugmented (abt, node); } @@ -167,7 +168,7 @@ abt_insert_after (struct abt *abt, const struct abt_node *p, struct abt_node *node) { assert (abt->compare == NULL); - insert_relative (abt, (struct abt_node *) p, true, node); + insert_relative (abt, p, true, node); } /* Inserts NODE before node P in ABT. @@ -180,7 +181,7 @@ abt_insert_before (struct abt *abt, const struct abt_node *p, struct abt_node *node) { assert (abt->compare == NULL); - insert_relative (abt, (struct abt_node *) p, false, node); + insert_relative (abt, p, false, node); } /* Deletes P from ABT. */ @@ -280,7 +281,7 @@ abt_find (const struct abt *abt, const struct abt_node *target) { cmp = abt->compare (target, p, abt->aux); if (cmp == 0) - return (struct abt_node *) p; + return CONST_CAST (struct abt_node *, p); } return NULL; @@ -307,7 +308,7 @@ abt_next (const struct abt *abt, const struct abt_node *p) p = p->down[1]; while (p->down[0] != NULL) p = p->down[0]; - return (struct abt_node *) p; + return CONST_CAST (struct abt_node *, p); } } @@ -332,7 +333,7 @@ abt_prev (const struct abt *abt, const struct abt_node *p) p = p->down[0]; while (p->down[1] != NULL) p = p->down[1]; - return (struct abt_node *) p; + return CONST_CAST (struct abt_node *, p); } }