*
* Returns the number of elements in b_node during the last loop.
*/
-static inline int mas_rebalance(struct ma_state *mas,
- struct maple_big_node *b_node)
+static inline int mas_rebalance(struct ma_state *mas, struct maple_big_node *b_node)
{
char empty_count = mas_mt_height(mas);
struct maple_subtree_state mast;
unsigned char end, space, split;
MA_STATE(tmp_mas, mas->tree, mas->index, mas->last);
- mas_dup_state(&tmp_mas, mast->l); // for depth.
+ tmp_mas.depth = mast->l->depth;
tmp_mas.node = mas->node;
if (left && !mas_prev_sibling(&tmp_mas))
mas_dup_state(&l_mas, mas);
mas_dup_state(&r_mas, mas);
- mast.l->node = mas_new_ma_node(mas, b_node);
- mast.r->node = mas_new_ma_node(mas, b_node);
+ l_mas.node = mas_new_ma_node(mas, b_node);
+ r_mas.node = mas_new_ma_node(mas, b_node);
if (mas_push_left(mas, height, &mast))
break;
if (mas_push_right(mas, height, &mast))
break;
- split = mab_calc_split(mas, mast.bn, &mid_split);
+ split = mab_calc_split(mas, b_node, &mid_split);
mast_split_data(&mast, mas, split);
// Usually correct, mab_mas_cp in the above call overwrites r->max.
mast.r->max = mas->max;