summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-31 05:23:36 +0000
committerDavid Robillard <d@drobilla.net>2011-01-31 05:23:36 +0000
commitd81b0c688ddb864fe6ebfee818dc1af76c7bc97b (patch)
tree009d3ac998a34eb63cb5de5632a84d402276a713
parentd5ad97feaff9bcb767d579c71451440a71b1464a (diff)
downloadlilv-d81b0c688ddb864fe6ebfee818dc1af76c7bc97b.tar.gz
lilv-d81b0c688ddb864fe6ebfee818dc1af76c7bc97b.tar.bz2
lilv-d81b0c688ddb864fe6ebfee818dc1af76c7bc97b.zip
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2887 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/plugin.c27
-rw-r--r--src/port.c9
-rw-r--r--src/world.c1
-rw-r--r--test/slv2_test.c8
4 files changed, 29 insertions, 16 deletions
diff --git a/src/plugin.c b/src/plugin.c
index bb18cb8..5ca27e4 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -118,6 +118,7 @@ slv2_plugin_query_node(SLV2Plugin p, librdf_node* subject, librdf_node* predicat
p, subject, predicate, NULL);
if (slv2_matches_end(results)) {
+ END_MATCH(results);
return NULL;
}
@@ -137,10 +138,7 @@ slv2_plugin_query_node(SLV2Plugin p, librdf_node* subject, librdf_node* predicat
SLV2Value
slv2_plugin_get_unique(SLV2Plugin p, librdf_node* subject, librdf_node* predicate)
{
- SLV2Values values = slv2_plugin_query_node(
- p,
- librdf_new_node_from_node(subject),
- librdf_new_node_from_node(predicate));
+ SLV2Values values = slv2_plugin_query_node(p, subject, predicate);
if (!values || slv2_values_size(values) != 1) {
SLV2_ERRORF("Port does not have exactly one `%s' property\n",
librdf_uri_as_string(librdf_node_get_uri(predicate)));
@@ -477,6 +475,7 @@ slv2_plugin_get_value_by_qname(SLV2Plugin p,
}
SLV2Value pred_value = slv2_value_new_uri(p->world, pred_uri);
SLV2Values ret = slv2_plugin_get_value(p, pred_value);
+
slv2_value_free(pred_value);
free(pred_uri);
return ret;
@@ -503,7 +502,6 @@ slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p,
librdf_free_node(pred_node);
free(pred_uri);
-
return slv2_values_from_stream_i18n(p, results);
}
@@ -527,10 +525,9 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p,
: librdf_new_node_from_blank_identifier(
p->world->world, (const uint8_t*)slv2_value_as_blank(subject));
- return slv2_plugin_query_node(
- p,
- subject_node,
- librdf_new_node_from_node(predicate->val.uri_val));
+ return slv2_plugin_query_node(p,
+ subject_node,
+ predicate->val.uri_val);
}
@@ -562,6 +559,10 @@ slv2_plugin_get_port_ranges_float(SLV2Plugin p,
if (def && def_values)
def_values[i] = slv2_value_as_float(def);
+
+ slv2_value_free(def);
+ slv2_value_free(min);
+ slv2_value_free(max);
}
}
@@ -618,12 +619,12 @@ slv2_plugin_has_latency(SLV2Plugin p)
port,
p->world->lv2_portproperty_node,
p->world->lv2_reportslatency_node);
- if (!slv2_matches_end(reports_latency)) {
+ const bool end = slv2_matches_end(reports_latency);
+ librdf_free_stream(reports_latency);
+ if (!end) {
ret = true;
break;
}
-
- librdf_free_stream(reports_latency);
}
END_MATCH(ports);
@@ -654,8 +655,10 @@ slv2_plugin_get_latency_port_index(SLV2Plugin p)
ret = slv2_value_as_int(index);
slv2_value_free(index);
+ END_MATCH(reports_latency);
break;
}
+ END_MATCH(reports_latency);
}
END_MATCH(ports);
diff --git a/src/port.c b/src/port.c
index 19692cc..a1c9046 100644
--- a/src/port.c
+++ b/src/port.c
@@ -81,7 +81,11 @@ slv2_port_get_node(SLV2Plugin p,
librdf_new_node_from_node(node),
librdf_new_node_from_node(p->world->lv2_symbol_node));
- if (slv2_value_equals(symbol, slv2_port_get_symbol(p, port))) {
+ const bool matches = slv2_value_equals(symbol,
+ slv2_port_get_symbol(p, port));
+
+ slv2_value_free(symbol);
+ if (matches) {
ret = librdf_new_node_from_node(node);
break;
}
@@ -136,6 +140,7 @@ static SLV2Values
slv2_values_from_stream_objects(SLV2Plugin p, SLV2Matches stream)
{
if (slv2_matches_end(stream)) {
+ END_MATCH(stream);
return NULL;
}
@@ -170,6 +175,7 @@ slv2_port_get_value_by_qname(SLV2Plugin p,
librdf_new_node_from_uri_string(p->world->world, (const uint8_t*)pred_uri),
NULL);
+ free(pred_uri);
return slv2_values_from_stream_objects(p, results);
}
@@ -227,6 +233,7 @@ slv2_port_get_value_by_qname_i18n(SLV2Plugin p,
librdf_new_node_from_uri_string(p->world->world, (const uint8_t*)pred_uri),
NULL);
+ free(pred_uri);
return slv2_values_from_stream_i18n(p, results);
}
diff --git a/src/world.c b/src/world.c
index 28868db..10de772 100644
--- a/src/world.c
+++ b/src/world.c
@@ -535,6 +535,7 @@ slv2_world_load_plugin_classes(SLV2World world)
NULL);
if (slv2_matches_end(parents)) {
+ END_MATCH(parents);
continue;
}
diff --git a/test/slv2_test.c b/test/slv2_test.c
index aafb3dd..9b0bd07 100644
--- a/test/slv2_test.c
+++ b/test/slv2_test.c
@@ -765,7 +765,9 @@ test_port()
TEST_ASSERT(slv2_port_is_a(plug, p, in_class));
TEST_ASSERT(!slv2_port_is_a(plug, p, audio_class));
- TEST_ASSERT(slv2_values_size(slv2_port_get_properties(plug, p)) == 1);
+ SLV2Values port_properties = slv2_port_get_properties(plug, p);
+ TEST_ASSERT(slv2_values_size(port_properties) == 1);
+ slv2_values_free(port_properties);
TEST_ASSERT(!strcmp(slv2_value_as_string(slv2_port_get_symbol(plug, p)), "foo"));
SLV2Value name = slv2_port_get_name(plug, p);
@@ -819,12 +821,12 @@ test_port()
SLV2Values names = slv2_port_get_value(plug, p, name_p);
TEST_ASSERT(slv2_values_size(names) == 2);
TEST_ASSERT(!strcmp(slv2_value_as_string(slv2_values_get_at(names, 0)),
- "bar"));
+ "bar"));
slv2_values_free(names);
names = slv2_port_get_value(plug, ep, name_p);
TEST_ASSERT(slv2_values_size(names) == 1);
TEST_ASSERT(!strcmp(slv2_value_as_string(slv2_values_get_at(names, 0)),
- "Event Input"));
+ "Event Input"));
slv2_values_free(names);
slv2_value_free(name_p);