diff options
author | David Robillard <d@drobilla.net> | 2012-03-02 05:19:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-02 05:19:21 +0000 |
commit | 8c8e3e1e306cb936be63cc033d8db2ca4442cbe5 (patch) | |
tree | 1a2a081f6041f8352e012819e3d26291b102b92c | |
parent | 8e241b6b299f3edc2d3e73b4b3a9e4235a949e33 (diff) | |
download | sratom-8c8e3e1e306cb936be63cc033d8db2ca4442cbe5.tar.gz sratom-8c8e3e1e306cb936be63cc033d8db2ca4442cbe5.tar.bz2 sratom-8c8e3e1e306cb936be63cc033d8db2ca4442cbe5.zip |
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/lad/trunk/sratom@4010 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/sratom.c | 7 | ||||
-rw-r--r-- | tests/sratom_test.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/sratom.c b/src/sratom.c index 4a15911..877f457 100644 --- a/src/sratom.c +++ b/src/sratom.c @@ -544,9 +544,8 @@ sratom_read_internal(Sratom* sratom, SordQuad match; SordQuad q2 = { node, 0, 0, 0 }; - for (SordIter* i = sord_find(model, q2); - !sord_iter_end(i); - sord_iter_next(i)) { + SordIter* i = sord_find(model, q2); + for (;!sord_iter_end(i); sord_iter_next(i)) { sord_iter_get(i, match); const SordNode* p = match[SORD_PREDICATE]; const char* p_uri = (const char*)sord_node_get_string(p); @@ -558,6 +557,7 @@ sratom_read_internal(Sratom* sratom, match[SORD_OBJECT], MODE_NORMAL); } } + sord_iter_free(i); } if (frame.ref) { lv2_atom_forge_pop(forge, &frame); @@ -638,6 +638,7 @@ sratom_from_turtle(Sratom* sratom, } else { fprintf(stderr, "Failed to find node\n"); } + sord_iter_free(i); } else { fprintf(stderr, "Failed to read Turtle\n"); } diff --git a/tests/sratom_test.c b/tests/sratom_test.c index 4ae3f9a..29ead8f 100644 --- a/tests/sratom_test.c +++ b/tests/sratom_test.c @@ -226,10 +226,15 @@ main() } printf("All tests passed.\n"); + + free(parsed); + free(instr); + free(outstr); sratom_free(sratom); for (uint32_t i = 0; i < n_uris; ++i) { free(uris[i]); } free(uris); + return 0; } |