From 7b17a6e66f422147ed911c6466d68421fcafe815 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 7 Mar 2015 07:38:59 +0000 Subject: Fix iteration during erase. git-svn-id: http://svn.drobilla.net/sord/trunk@326 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/sord.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/sord.c') diff --git a/src/sord.c b/src/sord.c index f9b8e53..104cc21 100644 --- a/src/sord.c +++ b/src/sord.c @@ -447,14 +447,14 @@ sord_iter_get_node(const SordIter* iter, SordQuadIndex index) return iter ? ((SordNode**)zix_btree_get(iter->cur))[index] : NULL; } -bool -sord_iter_next(SordIter* iter) +static bool +sord_iter_scan_next(SordIter* iter) { - if (iter->end) + if (iter->end) { return true; + } const SordNode** key; - iter->end = sord_iter_forward(iter); if (!iter->end) { switch (iter->mode) { case ALL: @@ -505,6 +505,17 @@ sord_iter_next(SordIter* iter) } } +bool +sord_iter_next(SordIter* iter) +{ + if (iter->end) { + return true; + } + + iter->end = sord_iter_forward(iter); + return sord_iter_scan_next(iter); +} + bool sord_iter_end(const SordIter* iter) { @@ -1258,6 +1269,7 @@ sord_erase(SordModel* sord, SordIter* iter) } } iter->end = zix_btree_iter_is_end(iter->cur); + sord_iter_scan_next(iter); free(quad); -- cgit v1.2.1