From cf127f3471242dea7ba60bfdaf7948a298bf5999 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Tue, 30 Jun 2020 16:42:30 +0800 Subject: [PATCH] [btree] Fix reference counts of children below a shadow --- persistent-data/data-structures/btree-remove.tcc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/persistent-data/data-structures/btree-remove.tcc b/persistent-data/data-structures/btree-remove.tcc index 9d3317e..852d267 100644 --- a/persistent-data/data-structures/btree-remove.tcc +++ b/persistent-data/data-structures/btree-remove.tcc @@ -94,10 +94,11 @@ namespace persistent_data { using namespace btree_detail; unsigned i = *index; - bool r = false; for (;;) { - r = spine.step(block); + bool inc = spine.step(block); + if (inc) + inc_children(spine, leaf_rc); // patch up the parent to point to the new shadow if (spine.has_parent()) { @@ -115,9 +116,9 @@ namespace persistent_data { return true; } - r = rebalance_children(spine, key); + bool r = rebalance_children(spine, key); if (!r) - break; + return false; n = spine.get_node(); if (n.get_type() == btree_detail::LEAF) { @@ -133,7 +134,7 @@ namespace persistent_data { block = n.value_at(i); } - return r; + return true; } template