};
#define NIL &sentinel /* all leafs are sentinels */
-static rbnode_t sentinel = { NIL, NIL, NULL, BLACK, NULL};
+static rbnode_t sentinel = { NIL, NIL, NIL, BLACK, NULL};
-#define NOT_AT_ROOT(_node) ((_node) != NULL)
+#define NOT_AT_ROOT(_node) ((_node) != NIL)
struct rbtree_t {
#ifndef NDEBUG
/* find where node belongs */
current = tree->root;
- parent = NULL;
+ parent = NIL;
while (current != NIL) {
int result;
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
+#include <assert.h>
#include <freeradius-devel/libradius.h>
}
}
ascend:
- if (!n->parent) return count_expect;
+ if (n->parent != NIL) return count_expect;
while (n->parent->right == n) {
n = n->parent;
if (!n->parent) return count_expect;
t = rbtree_create(NULL, comp, free, RBTREE_FLAG_LOCK);
/* Find out the value of the NIL node */
- NIL = t->root->left;
+ assert(t->root != NULL);
+ assert(t->root->parent == t->root);
+ NIL = t->root;
for (i = 0; i < n; i++) {
int *p;