/* 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
#endif
#include <libpspp/abt.h>
+#include <libpspp/cast.h>
#include <stdbool.h>
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;
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);
}
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.
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. */
{
cmp = abt->compare (target, p, abt->aux);
if (cmp == 0)
- return (struct abt_node *) p;
+ return CONST_CAST (struct abt_node *, p);
}
return NULL;
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);
}
}
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);
}
}