}
static inline void
-interval_stack_ensure_space (struct interval_stack *stack, intmax_t nelements)
+interval_stack_ensure_space (struct interval_stack *stack, uintmax_t nelements)
{
if (nelements > stack->size)
{
interval_stack_push_flagged (struct interval_stack *stack,
struct itree_node *node, bool flag)
{
- eassert (node && node != NULL);
+ eassert (node);
/* FIXME: While the stack used in the iterator is bounded by the tree
depth and could be easily pre-allocated to a large enough size to avoid
return g;
}
-static void
-itree_init (void)
+void
+init_itree (void)
{
iter = itree_iterator_create (NULL);
}
return node->end;
}
-/* Allocate an interval_tree. Free with interval_tree_destroy. */
+/* Allocate an itree_tree. Free with itree_destroy. */
struct itree_tree *
itree_create (void)
{
- /* FIXME? Maybe avoid the initialization of itree_null in the same
- way that is used to call mem_init in alloc.c? It's not really
- important though. */
- itree_init ();
-
struct itree_tree *tree = xmalloc (sizeof (*tree));
itree_clear (tree);
return tree;
/* Initialize a pre-allocated tree (presumably on the stack). */
static void
-interval_tree_init (struct interval_tree *tree)
+interval_tree_init (struct itree_tree *tree)
{
- interval_tree_clear (tree);
- /* tree->iter = itree_iterator_create (tree); */
+ itree_clear (tree);
}
#endif
itree_destroy (struct itree_tree *tree)
{
eassert (tree->root == NULL);
- /* if (tree->iter)
- * itree_iterator_destroy (tree->iter); */
xfree (tree);
}
static void
interval_tree_insert (struct itree_tree *tree, struct itree_node *node)
{
- eassert (node->begin <= node->end && node != NULL);
+ eassert (node && node->begin <= node->end);
/* FIXME: The assertion below fails because `delete_all_overlays`
doesn't set left/right/parent to NULL. */
/* eassert (node->left == NULL && node->right == NULL
static bool
interval_tree_contains (struct itree_tree *tree, struct itree_node *node)
{
- eassert (node);
+ eassert (iter && node);
struct itree_node *other;
ITREE_FOREACH (other, tree, node->begin, PTRDIFF_MAX, ASCENDING)
if (other == node)
if (parent == NULL)
eassert (node == tree->root);
else
- eassert (node == NULL || node->parent == parent);
+ eassert (node == NULL || node->parent == parent);
while (parent != NULL && null_safe_is_black (node))
{
ptrdiff_t end, enum itree_order order,
const char *file, int line)
{
- /* struct itree_iterator *iter = tree->iter; */
+ eassert (iter);
if (iter->running)
{
fprintf (stderr,
void
itree_iterator_finish (struct itree_iterator *iter)
{
- eassert (iter->running);
+ eassert (iter && iter->running);
iter->running = false;
}
&& (node->begin != node->end || node->rear_advance))
interval_stack_push (saved, node);
}
- for (int i = 0; i < saved->length; ++i)
+ for (size_t i = 0; i < saved->length; ++i)
itree_remove (tree, nav_nodeptr (saved->nodes[i]));
/* We can't use an iterator here, because we can't effectively
struct itree_node *
itree_iterator_next (struct itree_iterator *g)
{
- eassert (g->running);
+ eassert (g && g->running);
struct itree_node *const null = NULL;
struct itree_node *node;
itree_iterator_narrow (struct itree_iterator *g,
ptrdiff_t begin, ptrdiff_t end)
{
- eassert (g->running);
+ eassert (g && g->running);
eassert (begin >= g->begin);
eassert (end <= g->end);
- g->begin = max (begin, g->begin);
- g->end = min (end, g->end);
+ g->begin = max (begin, g->begin);
+ g->end = min (end, g->end);
}
dump_interval_node (struct dump_context *ctx, struct itree_node *node,
dump_off parent_offset)
{
-#if CHECK_STRUCTS && !defined (HASH_interval_node_5765524F7E)
-# error "interval_node changed. See CHECK_STRUCTS comment in config.h."
+#if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13)
+# error "itree_node changed. See CHECK_STRUCTS comment in config.h."
#endif
struct itree_node out;
dump_object_start (ctx, &out, sizeof (out));
static dump_off
dump_overlay (struct dump_context *ctx, const struct Lisp_Overlay *overlay)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Overlay_1CD4249AEC)
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Overlay_EB4C05D8D2)
# error "Lisp_Overlay changed. See CHECK_STRUCTS comment in config.h."
#endif
START_DUMP_PVEC (ctx, &overlay->header, struct Lisp_Overlay, out);
static dump_off
dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
{
-#if CHECK_STRUCTS && !defined HASH_buffer_F0F08347A5
+#if CHECK_STRUCTS && !defined HASH_buffer_193CAA5E45
# error "buffer changed. See CHECK_STRUCTS comment in config.h."
#endif
struct buffer munged_buffer = *in_buffer;