summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c14
-rw-r--r--src/plugininstance.c5
-rw-r--r--src/pluginuiinstance.c3
-rw-r--r--src/slv2_internal.h12
-rw-r--r--src/world.c4
5 files changed, 28 insertions, 10 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 1533ac6..4b29a00 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -257,7 +257,7 @@ slv2_plugin_load(SLV2Plugin p)
}
typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature *const *);
- OpenFunc open_func = (OpenFunc)dlsym(lib, "lv2_dyn_manifest_open");
+ OpenFunc open_func = (OpenFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_open");
LV2_Dyn_Manifest_Handle handle = NULL;
if (open_func)
open_func(&handle, &dman_features);
@@ -265,7 +265,7 @@ slv2_plugin_load(SLV2Plugin p)
typedef int (*GetDataFunc)(LV2_Dyn_Manifest_Handle handle,
FILE* fp,
const char* uri);
- GetDataFunc get_data_func = (GetDataFunc)dlsym(lib, "lv2_dyn_manifest_get_data");
+ GetDataFunc get_data_func = (GetDataFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_get_data");
if (get_data_func) {
FILE* fd = tmpfile();
get_data_func(handle, fd, slv2_value_as_string(p->plugin_uri));
@@ -275,7 +275,7 @@ slv2_plugin_load(SLV2Plugin p)
}
typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle);
- CloseFunc close_func = (CloseFunc)dlsym(lib, "lv2_dyn_manifest_close");
+ CloseFunc close_func = (CloseFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_close");
if (close_func)
close_func(handle);
}
@@ -656,8 +656,12 @@ slv2_plugin_get_supported_features(SLV2Plugin p)
for (unsigned i = 0 ; i < n_required; ++i)
g_ptr_array_add(result, slv2_values_get_at(required, i));
- free(((GPtrArray*)optional)->pdata);
- free(((GPtrArray*)required)->pdata);
+ if (optional) {
+ free(((GPtrArray*)optional)->pdata);
+ }
+ if (required) {
+ free(((GPtrArray*)required)->pdata);
+ }
return result;
}
diff --git a/src/plugininstance.c b/src/plugininstance.c
index 9d1a2b8..ffe9b2b 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <dlfcn.h>
#include "slv2/plugin.h"
#include "slv2/plugininstance.h"
#include "slv2/types.h"
@@ -30,6 +29,7 @@
#include "slv2/value.h"
#include "slv2_internal.h"
+
SLV2Instance
slv2_plugin_instantiate(SLV2Plugin plugin,
double sample_rate,
@@ -56,7 +56,8 @@ slv2_plugin_instantiate(SLV2Plugin plugin,
return NULL;
}
- LV2_Descriptor_Function df = dlsym(lib, "lv2_descriptor");
+ LV2_Descriptor_Function df = (LV2_Descriptor_Function)
+ slv2_dlfunc(lib, "lv2_descriptor");
if (!df) {
SLV2_ERRORF("Could not find symbol 'lv2_descriptor', "
diff --git a/src/pluginuiinstance.c b/src/pluginuiinstance.c
index 7c5611e..1c2cd1c 100644
--- a/src/pluginuiinstance.c
+++ b/src/pluginuiinstance.c
@@ -59,7 +59,8 @@ slv2_ui_instantiate(SLV2Plugin plugin,
return NULL;
}
- LV2UI_DescriptorFunction df = dlsym(lib, "lv2ui_descriptor");
+ LV2UI_DescriptorFunction df = (LV2UI_DescriptorFunction)
+ slv2_dlfunc(lib, "lv2ui_descriptor");
if (!df) {
SLV2_ERRORF("Could not find symbol 'lv2ui_descriptor', "
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 1c87a5e..2691c5d 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -30,6 +30,7 @@ extern "C" {
#include <stdint.h>
#include <stdlib.h>
#include <inttypes.h>
+#include <dlfcn.h>
#include <glib.h>
#include "serd/serd.h"
#include "sord/sord.h"
@@ -322,6 +323,17 @@ char* slv2_strjoin(const char* first, ...);
const char* slv2_get_lang();
uint8_t* slv2_qname_expand(SLV2Plugin p, const char* qname);
+typedef void (*VoidFunc)();
+
+/** dlsym wrapper to return a function pointer (without annoying warning) */
+static inline VoidFunc
+slv2_dlfunc(void* handle, const char* symbol)
+{
+ typedef VoidFunc (*VoidFuncGetter)(void*, const char*);
+ VoidFuncGetter dlfunc = (VoidFuncGetter)dlsym;
+ return dlfunc(handle, symbol);
+}
+
/* ********* Dynamic Manifest ********* */
#ifdef SLV2_DYN_MANIFEST
static const LV2_Feature* const dman_features = { NULL };
diff --git a/src/world.c b/src/world.c
index 454fdec..08de7ab 100644
--- a/src/world.c
+++ b/src/world.c
@@ -267,13 +267,13 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
// Open dynamic manifest
typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature *const *);
- OpenFunc open_func = (OpenFunc)dlsym(lib, "lv2_dyn_manifest_open");
+ OpenFunc open_func = (OpenFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_open");
if (open_func)
open_func(&handle, &dman_features);
// Get subjects (the data that would be in manifest.ttl)
typedef int (*GetSubjectsFunc)(LV2_Dyn_Manifest_Handle, FILE*);
- GetSubjectsFunc get_subjects_func = (GetSubjectsFunc)dlsym(lib,
+ GetSubjectsFunc get_subjects_func = (GetSubjectsFunc)slv2_dlfunc(lib,
"lv2_dyn_manifest_get_subjects");
if (!get_subjects_func)
continue;