From 3002e83149327ae4b16f71476640409c6442b897 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Mar 2011 03:26:54 +0000 Subject: 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 --- lvz/wrapper.cpp | 34 ++++++++++++++-------------------- 1 file 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; } -- cgit v1.2.1