Commit cc6e2aaa authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent ab2d0cdb
...@@ -478,17 +478,17 @@ split_interval_right (interval, offset) ...@@ -478,17 +478,17 @@ split_interval_right (interval, offset)
{ {
interval->right = new; interval->right = new;
new->total_length = new_length; new->total_length = new_length;
return new;
} }
else
/* Insert the new node between INTERVAL and its right child. */ {
new->right = interval->right; /* Insert the new node between INTERVAL and its right child. */
interval->right->parent = new; new->right = interval->right;
interval->right = new; interval->right->parent = new;
new->total_length = new_length + new->right->total_length; interval->right = new;
new->total_length = new_length + new->right->total_length;
balance_an_interval (new); balance_an_interval (new);
}
balance_possible_root_interval (interval); balance_possible_root_interval (interval);
return new; return new;
...@@ -524,17 +524,17 @@ split_interval_left (interval, offset) ...@@ -524,17 +524,17 @@ split_interval_left (interval, offset)
{ {
interval->left = new; interval->left = new;
new->total_length = new_length; new->total_length = new_length;
return new;
} }
else
/* Insert the new node between INTERVAL and its left child. */ {
new->left = interval->left; /* Insert the new node between INTERVAL and its left child. */
new->left->parent = new; new->left = interval->left;
interval->left = new; new->left->parent = new;
new->total_length = new_length + new->left->total_length; interval->left = new;
new->total_length = new_length + new->left->total_length;
balance_an_interval (new); balance_an_interval (new);
}
balance_possible_root_interval (interval); balance_possible_root_interval (interval);
return new; return new;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment