* subtree is not red-black.
*/
+#ifdef EXTREME_DICT_DEBUG
static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
{
unsigned height_left, height_right;
}
return 1;
}
+#endif
/*
* Compute the actual count of nodes by traversing the tree and
* detect a mismatch.
*/
+#ifdef EXTREME_DICT_DEBUG
static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root)
{
if (root == nil)
return 1 + verify_node_count(nil, root->left)
+ verify_node_count(nil, root->right);
}
+#endif
/*
* Verify that the tree contains the given node. This is done by
{
dict_t *new = XCALLOC(MTYPE_ISIS_DICT, sizeof(dict_t));
- if (new) {
- new->compare = comp;
- new->allocnode = dnode_alloc;
- new->freenode = dnode_free;
- new->context = NULL;
- new->nodecount = 0;
- new->maxcount = maxcount;
- new->nilnode.left = &new->nilnode;
- new->nilnode.right = &new->nilnode;
- new->nilnode.parent = &new->nilnode;
- new->nilnode.color = dnode_black;
- new->dupes = 0;
- }
+ new->compare = comp;
+ new->allocnode = dnode_alloc;
+ new->freenode = dnode_free;
+ new->context = NULL;
+ new->nodecount = 0;
+ new->maxcount = maxcount;
+ new->nilnode.left = &new->nilnode;
+ new->nilnode.right = &new->nilnode;
+ new->nilnode.parent = &new->nilnode;
+ new->nilnode.color = dnode_black;
+ new->dupes = 0;
+
return new;
}
int dict_verify(dict_t *dict)
{
+#ifdef EXTREME_DICT_DEBUG
dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
/* check that the sentinel node and root node are black */
return 0;
if (verify_node_count(nil, root) != dict_count(dict))
return 0;
+#endif
return 1;
}
dnode_t *dnode_create(void *data)
{
dnode_t *new = XCALLOC(MTYPE_ISIS_DICT_NODE, sizeof(dnode_t));
- if (new) {
- new->data = data;
- new->parent = NULL;
- new->left = NULL;
- new->right = NULL;
- }
+
+ new->data = data;
+ new->parent = NULL;
+ new->left = NULL;
+ new->right = NULL;
+
return new;
}
{
int sz = strlen(str) + 1;
char *new = XCALLOC(MTYPE_ISIS_TMP, sz);
- if (new)
- memcpy(new, str, sz);
+
+ memcpy(new, str, sz);
return new;
}
free(val);
if (dn)
dnode_destroy(dn);
- }
-
- dict_load_next(&dl, dn, key);
+ } else
+ dict_load_next(&dl, dn, key);
break;
default:
putchar('?');