summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-01-29 22:49:40 +0000
committerDavid Robillard <d@drobilla.net>2015-01-29 22:49:40 +0000
commit48648e4330b224391307343198152cce4f446874 (patch)
treecd643b485161a7ea2bea5497a01788d06c0d2e8d /src
parent4ff9f0b0b78681e4015feb1b2a54ec6f7becf563 (diff)
downloadlilv-48648e4330b224391307343198152cce4f446874.tar.gz
lilv-48648e4330b224391307343198152cce4f446874.tar.bz2
lilv-48648e4330b224391307343198152cce4f446874.zip
Add lilv_file_uri_parse() for correct URI to path conversion.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5528 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/instance.c7
-rw-r--r--src/lib.c6
-rw-r--r--src/util.c6
3 files changed, 16 insertions, 3 deletions
diff --git a/src/instance.c b/src/instance.c
index a3e2c91..ef64405 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -33,11 +33,12 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
const LilvNode* const lib_uri = lilv_plugin_get_library_uri(plugin);
const LilvNode* const bundle_uri = lilv_plugin_get_bundle_uri(plugin);
- const char* bundle_path = lilv_uri_to_path(
- lilv_node_as_uri(lilv_plugin_get_bundle_uri(plugin)));
+ char* const bundle_path = lilv_file_uri_parse(
+ lilv_node_as_uri(lilv_plugin_get_bundle_uri(plugin)), NULL);
LilvLib* lib = lilv_lib_open(plugin->world, lib_uri, bundle_path, features);
if (!lib) {
+ free(bundle_path);
return NULL;
}
@@ -46,6 +47,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
SerdURI base_uri;
if (serd_uri_parse((const uint8_t*)bundle_uri_str, &base_uri)) {
lilv_lib_close(lib);
+ free(bundle_path);
return NULL;
}
@@ -93,6 +95,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
}
free(local_features);
+ free(bundle_path);
if (result) {
// Failed to instantiate
diff --git a/src/lib.c b/src/lib.c
index 22c0437..ddf3d8e 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -33,7 +33,7 @@ lilv_lib_open(LilvWorld* world,
}
const char* const lib_uri = lilv_node_as_uri(uri);
- const char* const lib_path = lilv_uri_to_path(lib_uri);
+ char* const lib_path = lilv_file_uri_parse(lib_uri, NULL);
if (!lib_path) {
return NULL;
}
@@ -42,6 +42,7 @@ lilv_lib_open(LilvWorld* world,
void* lib = dlopen(lib_path, RTLD_NOW);
if (!lib) {
LILV_ERRORF("Failed to open library %s (%s)\n", lib_path, dlerror());
+ free(lib_path);
return NULL;
}
@@ -56,14 +57,17 @@ lilv_lib_open(LilvWorld* world,
desc = ldf(bundle_path, features);
if (!desc) {
LILV_ERRORF("Call to `lv2_lib_descriptor' in %s failed\n", lib_path);
+ free(lib_path);
return NULL;
}
} else if (!df) {
LILV_ERRORF("No `lv2_descriptor' or `lv2_lib_descriptor' in %s\n",
lib_path);
dlclose(lib);
+ free(lib_path);
return NULL;
}
+ free(lib_path);
LilvLib* llib = (LilvLib*)malloc(sizeof(LilvLib));
llib->world = world;
diff --git a/src/util.c b/src/util.c
index 65688b2..31c9238 100644
--- a/src/util.c
+++ b/src/util.c
@@ -118,6 +118,12 @@ lilv_uri_to_path(const char* uri)
return (const char*)serd_uri_to_path((const uint8_t*)uri);
}
+char*
+lilv_file_uri_parse(const char* uri, char** hostname)
+{
+ return (char*)serd_file_uri_parse((const uint8_t*)uri, (uint8_t**)hostname);
+}
+
/** Return the current LANG converted to Turtle (i.e. RFC3066) style.
* For example, if LANG is set to "en_CA.utf-8", this returns "en-ca".
*/