summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-03 21:06:07 +0000
committerDavid Robillard <d@drobilla.net>2009-06-03 21:06:07 +0000
commitc220a3ce918293855ed6b53b97dc604573fd031a (patch)
tree1d2bded722d47255d34e886493a9bf6ca5afc07f /src
parent150469fe73ff662738be01717173d252d989dce9 (diff)
downloadlilv-c220a3ce918293855ed6b53b97dc604573fd031a.tar.gz
lilv-c220a3ce918293855ed6b53b97dc604573fd031a.tar.bz2
lilv-c220a3ce918293855ed6b53b97dc604573fd031a.zip
Fix memory leaks.
Avoid unnecessary URI copy on plugin load. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2085 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c4
-rw-r--r--src/world.c14
2 files changed, 11 insertions, 7 deletions
diff --git a/src/plugin.c b/src/plugin.c
index bb294a8..baea5f5 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -208,10 +208,8 @@ slv2_plugin_load(SLV2Plugin p)
// Parse all the plugin's data files into RDF model
for (unsigned i=0; i < slv2_values_size(p->data_uris); ++i) {
SLV2Value data_uri_val = slv2_values_get_at(p->data_uris, i);
- librdf_uri* data_uri = librdf_new_uri(p->world->world,
- (const unsigned char*)slv2_value_as_uri(data_uri_val));
+ librdf_uri* data_uri = slv2_value_as_librdf_uri(data_uri_val);
librdf_parser_parse_into_model(p->world->parser, data_uri, NULL, p->rdf);
- librdf_free_uri(data_uri);
}
}
diff --git a/src/world.c b/src/world.c
index e2d5c6e..5b0d25a 100644
--- a/src/world.c
+++ b/src/world.c
@@ -176,6 +176,11 @@ slv2_world_load_file(SLV2World world, librdf_uri* file_uri)
void
slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
{
+ if (!slv2_value_is_uri(bundle_uri)) {
+ fprintf(stderr, "ERROR: slv2_world_load_bundle called with non-URI argument\n");
+ return;
+ }
+
librdf_uri* manifest_uri = librdf_new_uri_relative_to_base(
bundle_uri->val.uri_val, (const unsigned char*)"manifest.ttl");
@@ -464,8 +469,6 @@ slv2_world_load_plugin_classes(SLV2World world)
plugin_class = prev;
}
- SLV2Value uri = slv2_value_new_librdf_uri(world, class_uri);
-
// If this class differs from the last, append a new one
if (!plugin_class) {
if (n_classes == 0) {
@@ -491,12 +494,14 @@ slv2_world_load_plugin_classes(SLV2World world)
// Otherwise the query engine is giving us unsorted results :/
} else {
+ SLV2Value uri = slv2_value_new_librdf_uri(world, class_uri);
plugin_class = slv2_plugin_classes_get_by_uri(classes, uri);
if (!plugin_class) {
plugin_class = slv2_plugin_class_new(world, parent_uri, class_uri, label);
raptor_sequence_push(classes, plugin_class);
raptor_sequence_sort(classes, slv2_plugin_class_compare_by_uri);
}
+ slv2_value_free(uri);
}
}
} else {
@@ -587,10 +592,9 @@ slv2_world_load_all(SLV2World world)
plugin = prev;
}
- SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri);
-
// If this plugin differs from the last, append a new one
if (!plugin) {
+ SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri);
if (n_plugins == 0) {
plugin = slv2_plugin_new(world, uri, bundle_uri);
raptor_sequence_push(world->plugins, plugin);
@@ -619,6 +623,8 @@ slv2_world_load_all(SLV2World world)
plugin = slv2_plugin_new(world, uri, bundle_uri);
raptor_sequence_push(world->plugins, plugin);
raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri);
+ } else {
+ slv2_value_free(uri);
}
}
}