aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-03-15 03:26:54 +0000
committerDavid Robillard <d@drobilla.net>2011-03-15 03:26:54 +0000
commit3002e83149327ae4b16f71476640409c6442b897 (patch)
tree7374a3968c451b590b2a74cdfb5337e349447e12
parentd827ad88f41e5b2ae29b20d797b159a696f5849b (diff)
downloadmda.lv2-3002e83149327ae4b16f71476640409c6442b897.tar.gz
mda.lv2-3002e83149327ae4b16f71476640409c6442b897.tar.bz2
mda.lv2-3002e83149327ae4b16f71476640409c6442b897.zip
Use static descriptor (don't malloc and leak descriptor).
git-svn-id: http://svn.drobilla.net/lad/trunk/plugins/mdala.lv2@3086 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--lvz/wrapper.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/lvz/wrapper.cpp b/lvz/wrapper.cpp
index dd3611b..7ddcd7a 100644
--- a/lvz/wrapper.cpp
+++ b/lvz/wrapper.cpp
@@ -177,34 +177,28 @@ lvz_deactivate(LV2_Handle instance)
/* Library */
-static LV2_Descriptor *lvz_descriptor = NULL;
-
-static void
-init_descriptor()
-{
- lvz_descriptor = (LV2_Descriptor*)malloc(sizeof(LV2_Descriptor));
-
- lvz_descriptor->URI = URI_PREFIX PLUGIN_URI_SUFFIX;
- lvz_descriptor->instantiate = lvz_instantiate;
- lvz_descriptor->connect_port = lvz_connect_port;
- lvz_descriptor->activate = NULL;
- lvz_descriptor->run = lvz_run;
- lvz_descriptor->deactivate = lvz_deactivate;
- lvz_descriptor->cleanup = lvz_cleanup;
- lvz_descriptor->extension_data = lvz_extension_data;
-}
-
+static LV2_Descriptor descriptor;
+static bool initialised = false;
LV2_SYMBOL_EXPORT
const LV2_Descriptor*
lv2_descriptor(uint32_t index)
{
- if (!lvz_descriptor)
- init_descriptor();
+ if (!initialised) {
+ descriptor.URI = URI_PREFIX PLUGIN_URI_SUFFIX;
+ descriptor.instantiate = lvz_instantiate;
+ descriptor.connect_port = lvz_connect_port;
+ descriptor.activate = NULL;
+ descriptor.run = lvz_run;
+ descriptor.deactivate = lvz_deactivate;
+ descriptor.cleanup = lvz_cleanup;
+ descriptor.extension_data = lvz_extension_data;
+ initialised = true;
+ }
switch (index) {
case 0:
- return lvz_descriptor;
+ return &descriptor;
default:
return NULL;
}