summaryrefslogtreecommitdiff
path: root/src/intervals.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-02-16 23:46:08 +0000
committerRichard M. Stallman <rms@gnu.org>1998-02-16 23:46:08 +0000
commitcc6e2aaa2ae4f98baa4f450f4732f36e9a5c4061 (patch)
tree21ae79b7b227dc532f86170e965aa187f5fa7593 /src/intervals.c
parentab2d0cdb53b226e63c02730231a271312e940e12 (diff)
downloademacs-cc6e2aaa2ae4f98baa4f450f4732f36e9a5c4061.tar.gz
(split_interval_right): Make sure to call
balance_possible_root_interval in case an interval doesn't have a right child, because otherwise the interval tree might degenerate into a list. (split_interval_left): Ditto if an interval hasn't a left child.
Diffstat (limited to 'src/intervals.c')
-rw-r--r--src/intervals.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/intervals.c b/src/intervals.c
index 7bfdfa47c25..68561e1c892 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -478,17 +478,17 @@ split_interval_right (interval, offset)
{
interval->right = new;
new->total_length = new_length;
-
- return new;
}
-
- /* Insert the new node between INTERVAL and its right child. */
- new->right = interval->right;
- interval->right->parent = new;
- interval->right = new;
- new->total_length = new_length + new->right->total_length;
-
- balance_an_interval (new);
+ else
+ {
+ /* Insert the new node between INTERVAL and its right child. */
+ new->right = interval->right;
+ interval->right->parent = new;
+ interval->right = new;
+ new->total_length = new_length + new->right->total_length;
+ balance_an_interval (new);
+ }
+
balance_possible_root_interval (interval);
return new;
@@ -524,17 +524,17 @@ split_interval_left (interval, offset)
{
interval->left = new;
new->total_length = new_length;
-
- return new;
}
-
- /* Insert the new node between INTERVAL and its left child. */
- new->left = interval->left;
- new->left->parent = new;
- interval->left = new;
- new->total_length = new_length + new->left->total_length;
-
- balance_an_interval (new);
+ else
+ {
+ /* Insert the new node between INTERVAL and its left child. */
+ new->left = interval->left;
+ new->left->parent = new;
+ interval->left = new;
+ new->total_length = new_length + new->left->total_length;
+ balance_an_interval (new);
+ }
+
balance_possible_root_interval (interval);
return new;