summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-14 15:06:38 -0400
committerDavid Robillard <d@drobilla.net>2016-07-14 15:47:47 -0400
commit84ec2ee47279f87b4ed9ee44c9153f52a97732da (patch)
tree33ff024e51103ce035e51206ba1d8ba609769a30
parent9da2f26c8a8fcd533c61e9cfafb92a653131f285 (diff)
downloadlilv-84ec2ee47279f87b4ed9ee44c9153f52a97732da.tar.gz
lilv-84ec2ee47279f87b4ed9ee44c9153f52a97732da.tar.bz2
lilv-84ec2ee47279f87b4ed9ee44c9153f52a97732da.zip
Clean up and remove dead code
-rw-r--r--src/instance.c44
-rw-r--r--src/lib.c3
-rw-r--r--src/util.c11
-rw-r--r--src/world.c8
4 files changed, 17 insertions, 49 deletions
diff --git a/src/instance.c b/src/instance.c
index ff7b61f..9f27fa6 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2015 David Robillard <http://drobilla.net>
+ Copyright 2007-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -30,13 +30,11 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
return NULL;
}
- LilvInstance* result = NULL;
-
- const LilvNode* const lib_uri = lilv_plugin_get_library_uri(plugin);
- const LilvNode* const bundle_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);
+ LilvInstance* result = NULL;
+ const LilvNode* const lib_uri = lilv_plugin_get_library_uri(plugin);
+ const LilvNode* const bundle_uri = lilv_plugin_get_bundle_uri(plugin);
+ char* const bundle_path = lilv_file_uri_parse(
+ lilv_node_as_uri(bundle_uri), NULL);
LilvLib* lib = lilv_lib_open(plugin->world, lib_uri, bundle_path, features);
if (!lib) {
@@ -44,15 +42,6 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
return NULL;
}
- // Parse bundle URI to use as base URI
- const char* bundle_uri_str = lilv_node_as_uri(bundle_uri);
- SerdURI base_uri;
- if (serd_uri_parse((const uint8_t*)bundle_uri_str, &base_uri)) {
- lilv_lib_close(lib);
- lilv_free(bundle_path);
- return NULL;
- }
-
const LV2_Feature** local_features = NULL;
if (features == NULL) {
local_features = (const LV2_Feature**)malloc(sizeof(LV2_Feature*));
@@ -70,18 +59,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
break; // return NULL
}
- // Resolve library plugin URI against base URI
- SerdURI abs_uri;
- SerdNode abs_uri_node = serd_node_new_uri_from_string(
- (const uint8_t*)ld->URI, &base_uri, &abs_uri);
- if (!abs_uri_node.buf) {
- LILV_ERRORF("Failed to parse plugin URI `%s'\n", ld->URI);
- lilv_lib_close(lib);
- break;
- }
-
- if (!strcmp((const char*)abs_uri_node.buf,
- lilv_node_as_uri(lilv_plugin_get_uri(plugin)))) {
+ if (!strcmp(ld->URI, lilv_node_as_uri(lilv_plugin_get_uri(plugin)))) {
// Create LilvInstance to return
result = (LilvInstance*)malloc(sizeof(LilvInstance));
result->lv2_descriptor = ld;
@@ -89,10 +67,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
ld, sample_rate, bundle_path,
(features) ? features : local_features);
result->pimpl = lib;
- serd_node_free(&abs_uri_node);
break;
- } else {
- serd_node_free(&abs_uri_node);
}
}
@@ -100,15 +75,16 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
lilv_free(bundle_path);
if (result) {
- // Failed to instantiate
if (result->lv2_handle == NULL) {
+ // Failed to instantiate
free(result);
return NULL;
}
// "Connect" all ports to NULL (catches bugs)
- for (uint32_t i = 0; i < lilv_plugin_get_num_ports(plugin); ++i)
+ for (uint32_t i = 0; i < lilv_plugin_get_num_ports(plugin); ++i) {
result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL);
+ }
}
return result;
diff --git a/src/lib.c b/src/lib.c
index 7438c0c..8470684 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -87,8 +87,7 @@ lilv_lib_get_plugin(LilvLib* lib, uint32_t index)
{
if (lib->lv2_descriptor) {
return lib->lv2_descriptor(index);
- }
- if (lib->desc) {
+ } else if (lib->desc) {
return lib->desc->get_plugin(lib->desc->handle, index);
}
return NULL;
diff --git a/src/util.c b/src/util.c
index 5b38259..6cc7cc5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -602,19 +602,16 @@ lilv_file_equals(const char* a_path, const char* b_path)
FILE* b_file = NULL;
char* const a_real = lilv_realpath(a_path);
char* const b_real = lilv_realpath(b_path);
- if (!a_real || !b_real) {
- match = false; // Missing file matches nothing
- } else if (!strcmp(a_real, b_real)) {
+ if (!strcmp(a_real, b_real)) {
match = true; // Real paths match
} else if (lilv_file_size(a_path) != lilv_file_size(b_path)) {
match = false; // Sizes differ
- } else if (!(a_file = fopen(a_real, "rb"))) {
- match = false; // Missing file matches nothing
- } else if (!(b_file = fopen(b_real, "rb"))) {
+ } else if (!(a_file = fopen(a_real, "rb")) ||
+ !(b_file = fopen(b_real, "rb"))) {
match = false; // Missing file matches nothing
} else {
- match = true;
// TODO: Improve performance by reading chunks
+ match = true;
while (!feof(a_file) && !feof(b_file)) {
if (fgetc(a_file) != fgetc(b_file)) {
match = false;
diff --git a/src/world.c b/src/world.c
index e1f40c8..7428354 100644
--- a/src/world.c
+++ b/src/world.c
@@ -291,12 +291,8 @@ lilv_new_uri_relative_to_base(const uint8_t* uri_str,
const uint8_t* base_uri_str)
{
SerdURI base_uri;
- if (serd_uri_parse(base_uri_str, &base_uri)) {
- return SERD_NODE_NULL;
- }
-
- SerdURI ignored;
- return serd_node_new_uri_from_string(uri_str, &base_uri, &ignored);
+ serd_uri_parse(base_uri_str, &base_uri);
+ return serd_node_new_uri_from_string(uri_str, &base_uri, NULL);
}
const uint8_t*