| | /* Examines the binary tree rooted at node.
Zeroes *okay if an error occurs. Otherwise, does not modify *okay.
Sets *count to the number of nodes in that tree, including node itself if node != NULL.
Sets *bh to the tree's black-height.
All the nodes in the tree are verified to be at least min but no greater than max. */
static void recurse_verify_tree (struct prb_node *node, int *okay, size_t *count,
int min, int max, int *bh) {
int d; /* Value of this node's data. */
size_t subcount[2]; /* Number of nodes in subtrees. */
int subbh[2]; /* Black-heights of subtrees. */
int i;
if (node == NULL) {
*count = 0;
*bh = 0;
return;
}
d = *(int *) node->prb_data;
<@xref{\NODE\, , Verify binary search tree ordering.>,114}
recurse_verify_tree (node->prb_link[0], okay, &subcount[0],
min, d - 1, &subbh[0]);
recurse_verify_tree (node->prb_link[1], okay, &subcount[1],
d + 1, max, &subbh[1]);
*count = 1 + subcount[0] + subcount[1];
*bh = (node->prb_color == PRB_BLACK) + subbh[0];
<@xref{\NODE\, , Verify RB node color; rb =>.> prb,241}
<@xref{\NODE\, , Verify RB node rule 1 compliance; rb =>.> prb,242}
<@xref{\NODE\, , Verify RB node rule 2 compliance; rb =>.> prb,243}
<@xref{\NODE\, , Verify PBST node parent pointers; pbst =>.> prb,518}
}
|