summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-03-07 07:38:59 +0000
committerDavid Robillard <d@drobilla.net>2015-03-07 07:38:59 +0000
commit7b17a6e66f422147ed911c6466d68421fcafe815 (patch)
tree8f1d80127f727c938f261f2c72f153bbb83ed5d7 /src
parent3901fb804735d1791aa81e71d4c61396beb02b27 (diff)
downloadsord-7b17a6e66f422147ed911c6466d68421fcafe815.tar.gz
sord-7b17a6e66f422147ed911c6466d68421fcafe815.tar.bz2
sord-7b17a6e66f422147ed911c6466d68421fcafe815.zip
Fix iteration during erase.
git-svn-id: http://svn.drobilla.net/sord/trunk@326 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src')
-rw-r--r--src/sord.c20
1 files changed, 16 insertions, 4 deletions
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:
@@ -506,6 +506,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)
{
return !iter || iter->end;
@@ -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);