diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-12-07 22:03:34 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-12-07 22:03:34 +0100 |
commit | 5d2c1504bb0f88a5b823407ccfb5935069444577 (patch) | |
tree | 58ec703f56b39ab066e26d2cc4190b38ec9d1b76 | |
parent | 4e945783664221b428c0228248dc74278d86f524 (diff) |
Fix two minor bugs in the BPT implementation.
-rw-r--r-- | bitmapped_patricia_tree.c | 6 |
1 files 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) { |