From 978e99c6034845c01adb440811e0951f8215f6bb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 23 Apr 2011 20:58:57 +0000 Subject: Fix some memory leaks. git-svn-id: http://svn.drobilla.net/sord/trunk@83 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/sord_test.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/sord_test.c') diff --git a/src/sord_test.c b/src/sord_test.c index 6f6b45a..8a3c88b 100644 --- a/src/sord_test.c +++ b/src/sord_test.c @@ -76,17 +76,18 @@ generate(SordWorld world, SordModel sord, size_t n_quads, size_t n_objects_per) } // Add some literals - SordQuad tup; + SordQuad tup = { 0, 0, 0, 0}; tup[0] = uri(world, 98); tup[1] = uri(world, 4); - tup[2] = sord_new_literal(world, 0, (const uint8_t*)"hello", NULL); + tup[2] = sord_new_literal(world, 0, USTR("hello"), NULL); tup[3] = 0; sord_add(sord, tup); sord_node_free(world, tup[2]); tup[2] = sord_new_literal(world, 0, USTR("hi"), NULL); sord_add(sord, tup); - sord_node_free(world, tup[2]); + sord_node_free(world, tup[0]); + sord_node_free(world, tup[2]); tup[0] = uri(world, 14); tup[2] = sord_new_literal(world, 0, USTR("bonjour"), "fr"); sord_add(sord, tup); @@ -108,9 +109,9 @@ generate(SordWorld world, SordModel sord, size_t n_quads, size_t n_objects_per) sord_node_free(world, tup[0]); tup[0] = sord_new_blank(world, USTR("ablank")); sord_add(sord, tup); + sord_node_free(world, tup[1]); sord_node_free(world, tup[2]); - tup[1] = uri(world, 6); tup[2] = uri(world, 7); sord_add(sord, tup); @@ -210,6 +211,7 @@ test_read(SordWorld world, SordModel sord, const size_t n_quads, const int n_obj } } fprintf(stderr, "OK\n"); + sord_node_free(world, pat[0]); sord_iter_free(iter); if (num_results != 2) { fprintf(stderr, "Blank node subject query failed\n"); @@ -282,7 +284,7 @@ test_write(SordModel sord, const size_t n_quads, const int n_objects_per) int main(int argc, char** argv) { - static const size_t n_quads = 300; + static const size_t n_quads = 300; static const int n_objects_per = 2; sord_free(NULL); // Shouldn't crash @@ -295,6 +297,7 @@ main(int argc, char** argv) if (test_read(world, sord, n_quads, n_objects_per)) { sord_free(sord); + sord_world_free(world); return EXIT_FAILURE; } @@ -361,12 +364,12 @@ main(int argc, char** argv) goto fail; sord_free(sord); - sord_world_free(world); return EXIT_SUCCESS; fail: sord_free(sord); + sord_world_free(world); return EXIT_FAILURE; } -- cgit v1.2.1