summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-09-18 14:03:24 -0400
committerDavid Robillard <d@drobilla.net>2016-09-18 14:05:31 -0400
commit1d9bc02f315cd8a0abbece347ed398677524a258 (patch)
tree63a1097151579b3140daa5d14ec0376acdb478ff
parent5d9d21f6c9146fad15536ec90af68460fb634320 (diff)
downloadsord-1d9bc02f315cd8a0abbece347ed398677524a258.tar.gz
sord-1d9bc02f315cd8a0abbece347ed398677524a258.tar.bz2
sord-1d9bc02f315cd8a0abbece347ed398677524a258.zip
Fix erasing default graph iterators
-rw-r--r--src/sord.c2
-rw-r--r--src/sord_test.c5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/sord.c b/src/sord.c
index 9a0dd58..218234b 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -1266,7 +1266,7 @@ sord_erase(SordModel* sord, SordIter* iter)
SordNode* quad = NULL;
for (unsigned i = 0; i < NUM_ORDERS; ++i) {
- if (sord->indices[i]) {
+ if (sord->indices[i] && (i < GSPO || tup[3])) {
if (zix_btree_remove(sord->indices[i], tup, (void**)&quad,
i == iter->order ? &iter->cur : NULL)) {
return (i == 0) ? SERD_ERR_NOT_FOUND : SERD_ERR_INTERNAL;
diff --git a/src/sord_test.c b/src/sord_test.c
index 5eeb6d6..6c74017 100644
--- a/src/sord_test.c
+++ b/src/sord_test.c
@@ -684,9 +684,10 @@ main(int argc, char** argv)
}
sord_iter_free(iter);
+ // Erase the first tuple (an element in the default graph)
iter = sord_begin(sord);
- if (!sord_erase(sord, iter)) {
- return test_fail("Succesfully erased iterator on empty model\n");
+ if (sord_erase(sord, iter)) {
+ return test_fail("Failed to erase begin iterator on non-empty model\n");
}
// Ensure only the other graph is left