Expose a function to free memory allocated by the library
This commit is contained in:
parent
bc4cf8a5ad
commit
bd68a4fbb0
4 changed files with 16 additions and 3 deletions
|
|
@ -1707,7 +1707,7 @@ midnam_export(LV2_Handle instance)
|
|||
static void
|
||||
midnam_free(char *string)
|
||||
{
|
||||
free(string);
|
||||
sfizz_free_memory(string);
|
||||
}
|
||||
|
||||
static const void *
|
||||
|
|
|
|||
10
src/sfizz.h
10
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
|
||||
* @{
|
||||
|
|
|
|||
|
|
@ -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<sfizz_client_t*>(new sfz::Client(data));
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ TEST_CASE("[Bindings] Midnam C")
|
|||
REQUIRE(xmlMidnam.find("<Note Number=\"65\" Name=\"Crash\" />") != xmlMidnam.npos);
|
||||
REQUIRE(xmlMidnam.find("<Control Type=\"7bit\" Number=\"54\" Name=\"Gain\" />") != xmlMidnam.npos);
|
||||
REQUIRE(xmlMidnam.find("<Control Type=\"7bit\" Number=\"2\" Name=\"Other\" />") != xmlMidnam.npos);
|
||||
free(midnamChar);
|
||||
sfizz_free_memory(midnamChar);
|
||||
sfizz_free(synth);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue