summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-30 14:44:56 +0000
committerDavid Robillard <d@drobilla.net>2009-03-30 14:44:56 +0000
commitd909a9f409849dfe4072f2f57fdd2349ca8a0a3c (patch)
tree4364f25265aca621db2208505e39f4f183ff7b5a
parent8a24811ad2d2e587af6fe5ad487af08f74bccf38 (diff)
downloadlilv-d909a9f409849dfe4072f2f57fdd2349ca8a0a3c.tar.gz
lilv-d909a9f409849dfe4072f2f57fdd2349ca8a0a3c.tar.bz2
lilv-d909a9f409849dfe4072f2f57fdd2349ca8a0a3c.zip
Fix memory leaks.
Document ownership semantics of query value accessors. Fix test ccflags for new waf. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1951 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--slv2/query.h3
-rw-r--r--test/slv2_test.c14
-rw-r--r--test/wscript2
-rw-r--r--utils/lv2_inspect.c23
-rw-r--r--wscript2
5 files changed, 30 insertions, 14 deletions
diff --git a/slv2/query.h b/slv2/query.h
index aa25436..0c9c943 100644
--- a/slv2/query.h
+++ b/slv2/query.h
@@ -54,6 +54,7 @@ slv2_results_finished(SLV2Results results);
/** Return a binding in \a results by index.
* Indices correspond to selected variables in the query in order of appearance.
+ * Returned value must be freed by caller with slv2_value_free.
* \return NULL if binding value can not be expressed as an SLV2Value.
*/
SLV2Value
@@ -62,6 +63,7 @@ slv2_results_get_binding_value(SLV2Results results, unsigned index);
/** Return a binding in \a results by name.
* \a name corresponds to the name of the SPARQL variable (without the '?').
+ * Returned value must be freed by caller with slv2_value_free.
* \return NULL if binding value can not be expressed as an SLV2Value.
*/
SLV2Value
@@ -69,6 +71,7 @@ slv2_results_get_binding_value_by_name(SLV2Results results, const char* name);
/** Return the name of a binding in \a results.
+ * Returned value is shared and must not be freed by caller.
* Indices correspond to selected variables in the query in order of appearance.
*/
const char*
diff --git a/test/slv2_test.c b/test/slv2_test.c
index 65eba90..24f26a0 100644
--- a/test/slv2_test.c
+++ b/test/slv2_test.c
@@ -697,12 +697,14 @@ test_plugin()
"SELECT ?name WHERE { <> doap:maintainer [ foaf:name ?name ] }");
TEST_ASSERT(!slv2_results_finished(results));
TEST_ASSERT(!strcmp(slv2_results_get_binding_name(results, 0), "name"));
- TEST_ASSERT(!strcmp(
- slv2_value_as_string(slv2_results_get_binding_value(results, 0)),
- "David Robillard"));
- TEST_ASSERT(!strcmp(
- slv2_value_as_string(slv2_results_get_binding_value_by_name(results, "name")),
- "David Robillard"));
+ SLV2Value val = slv2_results_get_binding_value(results, 0);
+ TEST_ASSERT(!strcmp(slv2_value_as_string(val), "David Robillard"));
+ slv2_value_free(val);
+ val = slv2_results_get_binding_value_by_name(results, "name");
+ TEST_ASSERT(!strcmp(slv2_value_as_string(val), "David Robillard"));
+ slv2_value_free(val);
+
+ slv2_results_free(results);
slv2_uis_free(uis);
slv2_values_free(thing_names);
diff --git a/test/wscript b/test/wscript
index cd42778..93e7def 100644
--- a/test/wscript
+++ b/test/wscript
@@ -14,5 +14,5 @@ def build(bld):
obj.libs = 'gcov'
obj.target = i
obj.install_path = ''
- obj.ccflags = '-fprofile-arcs -ftest-coverage'
+ obj.ccflags = [ '-fprofile-arcs', '-ftest-coverage' ]
diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c
index f985a69..2bb13a4 100644
--- a/utils/lv2_inspect.c
+++ b/utils/lv2_inspect.c
@@ -262,6 +262,7 @@ print_usage()
int
main(int argc, char** argv)
{
+ int ret = 0;
setlocale (LC_ALL, "");
SLV2World world = slv2_world_new();
@@ -272,18 +273,22 @@ main(int argc, char** argv)
if (argc != 2) {
print_usage();
- return -1;
+ ret = 1;
+ goto done;
}
if (!strcmp(argv[1], "--version")) {
print_version();
- return 0;
+ ret = 0;
+ goto done;
} else if (!strcmp(argv[1], "--help")) {
print_usage();
- return 0;
+ ret = 0;
+ goto done;
} else if (argv[1][0] == '-') {
print_usage();
- return -1;
+ ret = 2;
+ goto done;
}
SLV2Plugins plugins = slv2_world_get_all_plugins(world);
@@ -297,9 +302,15 @@ main(int argc, char** argv)
fprintf(stderr, "Plugin not found.\n");
}
+ ret = (p != NULL ? 0 : -1);
+
slv2_value_free(uri);
slv2_plugins_free(world, plugins);
- slv2_world_free(world);
- return (p != NULL ? 0 : -1);
+done:
+ slv2_value_free(event_class);
+ slv2_value_free(control_class);
+ slv2_world_free(world);
+ return ret;
}
+
diff --git a/wscript b/wscript
index c2de807..f82e3ad 100644
--- a/wscript
+++ b/wscript
@@ -104,7 +104,7 @@ def build(bld):
obj.name = 'libslv2_static'
obj.target = 'slv2_static'
obj.install_path = ''
- obj.ccflags = '-fprofile-arcs -ftest-coverage'
+ obj.ccflags = [ '-fprofile-arcs', '-ftest-coverage' ]
# Utilities
utils = '''