/* The sentinel node, the null node. */
struct interval_node itree_null = {
- .parent = &itree_null,
+ .parent = NULL, /* never accessed */
.left = &itree_null,
.right = &itree_null,
.begin = PTRDIFF_MIN,
static bool
null_is_sane (void)
{
- /* The sentinel node has most of its fields read-only.
-
- FIXME: PARENT is still read/write. It is written to
- ininterval_tree_transplant, and later read. --matt
- */
- /* eassert (itree_null.parent == &itree_null); */
+ /* All sentinel node fields are read-only. */
+ eassert (itree_null.parent == NULL);
eassert (itree_null.left == &itree_null);
eassert (itree_null.right == &itree_null);
eassert (itree_null.begin == PTRDIFF_MIN);
other->red = false;
parent->red = true;
interval_tree_rotate_left (tree, parent);
- parent = node->parent;
other = parent->right;
}
other->left->red = false;
other->red = true;
interval_tree_rotate_right (tree, other);
- parent = node->parent;
other = parent->right;
}
other->red = parent->red; /* 4.a */
other->red = false;
parent->red = true;
interval_tree_rotate_right (tree, parent);
- parent = node->parent;
other = parent->left;
}
other->right->red = false;
other->red = true;
interval_tree_rotate_left (tree, other);
- parent = node->parent;
other = parent->left;
}
interval_tree_transplant (tree, min, node);
/* We set min->right->parent after `interval_tree_transplant` so
that calls to `itree_total_offset` don't get stuck in an inf-loop. */
- min->right->parent = min;
+ if (min->right != ITREE_NULL)
+ min->right->parent = min;
interval_tree_update_limit (min);
/* This call "belongs" with the first `interval_tree_transplant`
(of `min_right`, done earlier in the `if`) but we prefer to do it
else
dest->parent->right = source;
- source->parent = dest->parent;
+ if (source != ITREE_NULL)
+ source->parent = dest->parent;
}
\f