diff options
author | David Robillard <d@drobilla.net> | 2014-12-18 05:50:08 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-18 05:50:08 +0000 |
commit | f683a30a854af0d24c37ecba4ed848d29bf5a4ea (patch) | |
tree | 8631c94955ce100858c39e487f072ca4eee27687 /zix/btree.c | |
parent | ef4c9adf80f92ff9e628b21901316746b072eb4a (diff) | |
download | zix-f683a30a854af0d24c37ecba4ed848d29bf5a4ea.tar.gz zix-f683a30a854af0d24c37ecba4ed848d29bf5a4ea.tar.bz2 zix-f683a30a854af0d24c37ecba4ed848d29bf5a4ea.zip |
Fix unlikely tree bugs.
git-svn-id: http://svn.drobilla.net/zix/trunk@98 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
Diffstat (limited to 'zix/btree.c')
-rw-r--r-- | zix/btree.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/zix/btree.c b/zix/btree.c index 82a7955..4557ad4 100644 --- a/zix/btree.c +++ b/zix/btree.c @@ -306,12 +306,11 @@ zix_btree_insert(ZixBTree* const t, void* const e) n = n->children[i]; } else { // Insert into internal node - zix_btree_ainsert(n->vals, n->n_vals, i, e); + zix_btree_ainsert(n->vals, n->n_vals++, i, e); break; } } - ++n->n_vals; ++t->size; return ZIX_STATUS_SUCCESS; @@ -609,6 +608,11 @@ zix_btree_lower_bound(const ZixBTree* const t, const void* const e, ZixBTreeIter** const ti) { + if (!t) { + *ti = NULL; + return ZIX_STATUS_BAD_ARG; + } + ZixBTreeNode* n = t->root; bool found = false; unsigned found_level = 0; @@ -632,6 +636,7 @@ zix_btree_lower_bound(const ZixBTree* const t, } else { ++(*ti)->level; n = n->children[i]; + assert(n); } } |