From 5d2c1504bb0f88a5b823407ccfb5935069444577 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 7 Dec 2011 22:03:34 +0100 Subject: Fix two minor bugs in the BPT implementation. --- bitmapped_patricia_tree.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bitmapped_patricia_tree.c b/bitmapped_patricia_tree.c index d276cde..765b817 100644 --- a/bitmapped_patricia_tree.c +++ b/bitmapped_patricia_tree.c @@ -208,8 +208,7 @@ bpt_t bpt_assoc(bpt_t bpt, bpt_key_t key, void *value) { new_node->children[0] = bpt_make_leaf(key, value); new_node->children[1] = bpt; } - bpt_retain(new_node->children[0]); - bpt_retain(new_node->children[1]); + bpt_retain(bpt); return (bpt_t)new_node; } else { if (bpt->tag == BPT_LEAF) { @@ -310,8 +309,7 @@ bpt_t bpt_dissoc(bpt_t bpt, bpt_key_t key) { if (!new_child && number_of_children == 2) { // When there is only a single child left, we replace ourselves // with that child. - bpt_t remaining_child = (b->children[0] ? b->children[0] - : b->children[1]); + bpt_t remaining_child = b->children[1-child_index]; bpt_retain(remaining_child); return remaining_child; } else if (bpt->mutable) { -- cgit v1.2.3