From 828552916eb4e14a8f3dcf83b78687f9f34b1e4b Mon Sep 17 00:00:00 2001 From: Andreas Politz Date: Thu, 5 Oct 2017 21:55:43 +0200 Subject: [PATCH] Add offsets when inspecting a node's children's values *src/itree.c (interval_tree_insert_gap): Add offset. --- src/itree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/itree.c b/src/itree.c index 0c10100eef7..5df2d8d1cc5 100644 --- a/src/itree.c +++ b/src/itree.c @@ -519,7 +519,8 @@ interval_tree_insert_gap (struct interval_tree *tree, ptrdiff_t pos, ptrdiff_t l else interval_stack_push (stack, node->right); } - if (node->left != &tree->nil && pos <= node->left->limit) + if (node->left != &tree->nil + && pos <= node->left->limit + node->left->offset) interval_stack_push (stack, node->left); /* node->begin == pos implies no front-advance. */ @@ -578,7 +579,8 @@ interval_tree_delete_gap (struct interval_tree *tree, ptrdiff_t pos, ptrdiff_t l else interval_stack_push (stack, node->right); } - if (node->left != &tree->nil && pos <= node->left->limit) + if (node->left != &tree->nil + && pos <= node->left->limit + node->left->offset) interval_stack_push (stack, node->left); if (pos < node->begin) -- 2.39.2