summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-23 18:17:15 +0000
committerDavid Robillard <d@drobilla.net>2007-04-23 18:17:15 +0000
commiteda602d83c1a28f6a1654811affb00c78d25c8bf (patch)
tree02ac74cae8ada704afee766d9fa0018688b74324 /src
parent2a5e35c295d2df30e98cacb48ec3496a85c2d851 (diff)
downloadlilv-eda602d83c1a28f6a1654811affb00c78d25c8bf.tar.gz
lilv-eda602d83c1a28f6a1654811affb00c78d25c8bf.tar.bz2
lilv-eda602d83c1a28f6a1654811affb00c78d25c8bf.zip
Incorporated patch from larsl for reading plugin manifest files for plugin data.
Plugged several memory leaks. git-svn-id: http://svn.drobilla.net/lad/slv2@474 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c9
-rw-r--r--src/pluginclass.c1
-rw-r--r--src/world.c57
3 files changed, 60 insertions, 7 deletions
diff --git a/src/plugin.c b/src/plugin.c
index a3f9177..7efe6b7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -162,6 +162,8 @@ slv2_plugin_load(SLV2Plugin p)
SLV2PluginClass plugin_class = slv2_plugin_classes_get_by_uri(
p->world->plugin_classes, class_uri_str);
+
+ librdf_free_node(class_node);
if (plugin_class) {
p->plugin_class = plugin_class;
@@ -173,6 +175,9 @@ slv2_plugin_load(SLV2Plugin p)
if (p->plugin_class == NULL)
p->plugin_class = raptor_sequence_get_at(p->world->plugin_classes, 0); // lv2:Plugin
+
+ librdf_free_query_results(results);
+ librdf_free_query(q);
// Load ports
query = (const unsigned char*)
@@ -216,9 +221,7 @@ slv2_plugin_load(SLV2Plugin p)
raptor_sequence_sort(p->ports, slv2_port_compare_by_index);
- if (results)
- librdf_free_query_results(results);
-
+ librdf_free_query_results(results);
librdf_free_query(q);
//printf("%p %s: NUM PORTS: %d\n", (void*)p, p->plugin_uri, slv2_plugin_get_num_ports(p));
diff --git a/src/pluginclass.c b/src/pluginclass.c
index 8ffd66b..8aa4abb 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -43,6 +43,7 @@ void
slv2_plugin_class_free(SLV2PluginClass plugin_class)
{
free(plugin_class->uri);
+ free(plugin_class->parent_uri);
free(plugin_class->label);
free(plugin_class);
}
diff --git a/src/world.c b/src/world.c
index 9b9b5fa..fa4cf1e 100644
--- a/src/world.c
+++ b/src/world.c
@@ -93,8 +93,50 @@ slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
librdf_uri* manifest_uri = librdf_new_uri_relative_to_base(
bundle_uri, (const unsigned char*)"manifest.ttl");
- librdf_parser_parse_into_model(world->parser, manifest_uri, NULL, world->model);
+ /* Parse the manifest into a temporary model */
+ librdf_storage* manifest_storage = librdf_new_storage(world->world,
+ "hashes", NULL, "hash-type='memory'");
+ librdf_model* manifest_model = librdf_new_model(world->world,
+ manifest_storage, NULL);
+ librdf_parser_parse_into_model(world->parser, manifest_uri, NULL,
+ manifest_model);
+
+ /* Find any plugins declared in the manifest and add references
+ * to their manifest files as one of their data files */
+ unsigned char* query_string = (unsigned char*)
+ "PREFIX : <http://lv2plug.in/ontology#>\n"
+ "SELECT DISTINCT ?plugin\n"
+ "WHERE { ?plugin a :Plugin }\n";
+
+ librdf_query* q = librdf_new_query(world->world, "sparql",
+ NULL, query_string, NULL);
+
+ librdf_query_results* results = librdf_query_execute(q, manifest_model);
+
+ while (!librdf_query_results_finished(results)) {
+
+ librdf_node* plugin_node = librdf_query_results_get_binding_value(results, 0);
+
+ librdf_node* subject = plugin_node;
+ librdf_node* predicate = librdf_new_node_from_uri_string(world->world,
+ (unsigned char*)"http://www.w3.org/2000/01/rdf-schema#seeAlso");
+ librdf_node* object = librdf_new_node_from_uri(world->world,
+ manifest_uri);
+
+ librdf_model_add(world->model, subject, predicate, object);
+ librdf_query_results_next(results);
+ }
+
+ /* Join the temporary model to the main model */
+ librdf_stream* manifest_stream = librdf_model_as_stream(manifest_model);
+ librdf_model_add_statements(world->model, manifest_stream);
+ librdf_free_stream(manifest_stream);
+
+ librdf_free_query(q);
+ librdf_free_query_results(results);
+ librdf_free_model(manifest_model);
+ librdf_free_storage(manifest_storage);
librdf_free_uri(manifest_uri);
librdf_free_uri(bundle_uri);
}
@@ -205,10 +247,17 @@ slv2_world_load_plugin_classes(SLV2World world)
label);
raptor_sequence_push(world->plugin_classes, plugin_class);
+ librdf_free_node(class_node);
+ librdf_free_node(parent_node);
+ librdf_free_node(label_node);
+
librdf_query_results_next(results);
}
// FIXME: filter list here
+
+ librdf_free_query_results(results);
+ librdf_free_query(q);
}
@@ -270,9 +319,11 @@ slv2_world_load_all(SLV2World world)
(const char*)librdf_uri_as_string(plugin_uri));
// Create a new SLV2Plugin
- if (!plugin)
+ if (!plugin) {
plugin = slv2_plugin_new(world, plugin_uri,
(const char*)librdf_uri_as_string(binary_uri));
+ raptor_sequence_push(world->plugins, plugin);
+ }
plugin->world = world;
@@ -280,8 +331,6 @@ slv2_world_load_all(SLV2World world)
raptor_sequence_push(plugin->data_uris,
strdup((const char*)librdf_uri_as_string(data_uri)));
- raptor_sequence_push(world->plugins, plugin);
-
librdf_free_node(plugin_node);
librdf_free_node(data_node);
librdf_free_node(binary_node);