diff --git a/plugins/lv2/sfizz.cpp b/plugins/lv2/sfizz.cpp index 912c04b1..ec8e1518 100644 --- a/plugins/lv2/sfizz.cpp +++ b/plugins/lv2/sfizz.cpp @@ -1707,7 +1707,7 @@ midnam_export(LV2_Handle instance) static void midnam_free(char *string) { - free(string); + sfizz_free_memory(string); } static const void * diff --git a/src/sfizz.h b/src/sfizz.h index 6dee8b7b..3c776e1b 100644 --- a/src/sfizz.h +++ b/src/sfizz.h @@ -274,7 +274,7 @@ SFIZZ_EXPORTED_API int sfizz_get_num_curves(sfizz_synth_t* synth); * @param synth The synth. * @param model The model name used if a non-empty string, otherwise generated. * - * @return A newly allocated XML string, which must be freed after use. + * @return A newly allocated XML string, which must be freed after use using sfizz_free_memory(). */ SFIZZ_EXPORTED_API char* sfizz_export_midnam(sfizz_synth_t* synth, const char* model); @@ -1097,6 +1097,14 @@ SFIZZ_EXPORTED_API int sfizz_get_cc_label_number(sfizz_synth_t* synth, int label */ SFIZZ_EXPORTED_API const char * sfizz_get_cc_label_text(sfizz_synth_t* synth, int label_index); +/** + * @brief Free a block of memory allocated by the library. + * @brief 1.0.0 + * + * @param ptr The address of the memory to free. + */ +SFIZZ_EXPORTED_API void sfizz_free_memory(void* ptr); + /** * @addtogroup Messaging * @{ diff --git a/src/sfizz/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp index 4c5c4ca1..685c9ec7 100644 --- a/src/sfizz/sfizz_wrapper.cpp +++ b/src/sfizz/sfizz_wrapper.cpp @@ -410,6 +410,11 @@ const char * sfizz_get_cc_label_text(sfizz_synth_t* synth, int label_index) return ccLabels[label_index].second.c_str(); } +void sfizz_free_memory(void* ptr) +{ + free(ptr); +} + sfizz_client_t* sfizz_create_client(void* data) { return reinterpret_cast(new sfz::Client(data)); diff --git a/tests/BindingsT.cpp b/tests/BindingsT.cpp index 095c57ac..5ce32011 100644 --- a/tests/BindingsT.cpp +++ b/tests/BindingsT.cpp @@ -33,6 +33,6 @@ TEST_CASE("[Bindings] Midnam C") REQUIRE(xmlMidnam.find("") != xmlMidnam.npos); REQUIRE(xmlMidnam.find("") != xmlMidnam.npos); REQUIRE(xmlMidnam.find("") != xmlMidnam.npos); - free(midnamChar); + sfizz_free_memory(midnamChar); sfizz_free(synth); }