even more destructor refactor

This commit is contained in:
derselbst 2017-10-30 11:28:08 +01:00
parent 323320e7e4
commit bf978e2b6b
17 changed files with 41 additions and 90 deletions

View file

@ -303,6 +303,8 @@ fluid_shell_init(fluid_shell_t* shell,
void
delete_fluid_shell(fluid_shell_t* shell)
{
fluid_return_if_fail(shell != NULL);
if (shell->thread != NULL) {
delete_fluid_thread(shell->thread);
}
@ -2240,16 +2242,11 @@ fluid_cmd_t* fluid_cmd_copy(fluid_cmd_t* cmd)
void delete_fluid_cmd(fluid_cmd_t* cmd)
{
if (cmd->name) {
fluid_return_if_fail(cmd != NULL);
FLUID_FREE(cmd->name);
}
if (cmd->topic) {
FLUID_FREE(cmd->topic);
}
if (cmd->help) {
FLUID_FREE(cmd->help);
}
FLUID_FREE(cmd);
FLUID_FREE(cmd);
}
/*
@ -2316,6 +2313,8 @@ fluid_cmd_handler_t* new_fluid_cmd_handler(fluid_synth_t* synth, fluid_midi_rout
void
delete_fluid_cmd_handler(fluid_cmd_handler_t* handler)
{
fluid_return_if_fail(handler != NULL);
delete_fluid_hashtable(handler->commands);
FLUID_FREE(handler);
}
@ -2426,9 +2425,7 @@ new_fluid_server(fluid_settings_t* settings,
void
delete_fluid_server(fluid_server_t* server)
{
if (server == NULL) {
return;
}
fluid_return_if_fail(server != NULL);
fluid_server_close(server);
@ -2441,9 +2438,7 @@ static void fluid_server_close(fluid_server_t* server)
fluid_list_t* clients;
fluid_client_t* client;
if (server == NULL) {
return;
}
fluid_return_if_fail(server != NULL);
fluid_mutex_lock(server->mutex);
clients = server->clients;
@ -2565,10 +2560,8 @@ error_recovery:
void fluid_client_quit(fluid_client_t* client)
{
if (client->socket != INVALID_SOCKET) {
fluid_socket_close(client->socket);
client->socket = INVALID_SOCKET;
}
FLUID_LOG(FLUID_DBG, "fluid_client_quit: joining");
fluid_thread_join(client->thread);
FLUID_LOG(FLUID_DBG, "fluid_client_quit: done");
@ -2576,20 +2569,12 @@ void fluid_client_quit(fluid_client_t* client)
void delete_fluid_client(fluid_client_t* client)
{
if(client->handler != NULL)
{
fluid_return_if_fail(client != NULL);
delete_fluid_cmd_handler(client->handler);
client->handler = NULL;
}
if (client->socket != INVALID_SOCKET) {
fluid_socket_close(client->socket);
client->socket = INVALID_SOCKET;
}
if (client->thread != NULL) {
delete_fluid_thread(client->thread);
client->thread = NULL;
}
FLUID_FREE(client);
}

View file

@ -326,9 +326,7 @@ fluid_file_set_encoding_quality(fluid_file_renderer_t* r, double q)
*/
void delete_fluid_file_renderer(fluid_file_renderer_t* dev)
{
if (dev == NULL) {
return;
}
fluid_return_if_fail(dev != NULL);
#if LIBSNDFILE_SUPPORT
if (dev->sndfile != NULL) {

View file

@ -369,6 +369,7 @@ void
delete_fluid_audio_driver(fluid_audio_driver_t* driver)
{
unsigned int i;
fluid_return_if_fail(driver != NULL);
for (i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers); i++) {
if (fluid_audio_drivers[i].name == driver->name) {

View file

@ -321,7 +321,6 @@ new_fluid_alsa_audio_driver2(fluid_settings_t* settings,
void delete_fluid_alsa_audio_driver(fluid_audio_driver_t* p)
{
fluid_alsa_audio_driver_t* dev = (fluid_alsa_audio_driver_t*) p;
fluid_return_if_fail(dev != NULL);
dev->cont = 0;
@ -649,7 +648,6 @@ void
delete_fluid_alsa_rawmidi_driver(fluid_midi_driver_t* p)
{
fluid_alsa_rawmidi_driver_t* dev = (fluid_alsa_rawmidi_driver_t*) p;
fluid_return_if_fail(dev != NULL);
/* cancel the thread and wait for it before cleaning up */
@ -975,7 +973,6 @@ void
delete_fluid_alsa_seq_driver(fluid_midi_driver_t* p)
{
fluid_alsa_seq_driver_t* dev = (fluid_alsa_seq_driver_t*) p;
fluid_return_if_fail(dev != NULL);
/* cancel the thread and wait for it before cleaning up */

View file

@ -103,17 +103,11 @@ new_fluid_file_audio_driver(fluid_settings_t* settings,
void delete_fluid_file_audio_driver(fluid_audio_driver_t* p)
{
fluid_file_audio_driver_t* dev = (fluid_file_audio_driver_t*) p;
fluid_return_if_fail(dev != NULL);
if (dev->timer != NULL) {
delete_fluid_timer(dev->timer);
}
if (dev->renderer != NULL) {
delete_fluid_file_renderer(dev->renderer);
}
FLUID_FREE(dev);
}

View file

@ -319,10 +319,7 @@ void
delete_fluid_core_audio_driver(fluid_audio_driver_t* p)
{
fluid_core_audio_driver_t* dev = (fluid_core_audio_driver_t*) p;
if (dev == NULL) {
return;
}
fluid_return_if_fail(dev != NULL);
CloseComponent (dev->outputUnit);

View file

@ -162,9 +162,7 @@ void
delete_fluid_coremidi_driver(fluid_midi_driver_t* p)
{
fluid_coremidi_driver_t* dev = (fluid_coremidi_driver_t*) p;
if(dev == NULL)
return;
fluid_return_if_fail(dev != NULL);
if (dev->client != NULL) {
MIDIClientDispose(dev->client);

View file

@ -215,10 +215,7 @@ error_recovery:
void delete_fluid_dart_audio_driver(fluid_audio_driver_t* p)
{
fluid_dart_audio_driver_t* dev = (fluid_dart_audio_driver_t*) p;
if (dev == NULL) {
return;
}
fluid_return_if_fail(dev != NULL);
if (dev->usDeviceID != 0) {
MCI_GENERIC_PARMS GenericParms;

View file

@ -273,10 +273,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
void delete_fluid_dsound_audio_driver(fluid_audio_driver_t* d)
{
fluid_dsound_audio_driver_t* dev = (fluid_dsound_audio_driver_t*) d;
if (dev == NULL) {
return;
}
fluid_return_if_fail(dev != NULL);
/* tell the audio thread to stop its loop */
dev->cont = 0;

View file

@ -234,6 +234,7 @@ fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings, handle_mi
void delete_fluid_midi_driver(fluid_midi_driver_t* driver)
{
unsigned int i;
fluid_return_if_fail(driver != NULL);
for (i = 0; i < FLUID_N_ELEMENTS(fluid_midi_drivers); i++) {
if (fluid_midi_drivers[i].name == driver->name) {

View file

@ -247,9 +247,7 @@ void
delete_fluid_winmidi_driver(fluid_midi_driver_t* p)
{
fluid_winmidi_driver_t* dev = (fluid_winmidi_driver_t*) p;
if(dev == NULL)
return;
fluid_return_if_fail (dev != NULL);
if (dev->hmidiin != NULL) {
fluid_atomic_int_set (&dev->closing, TRUE);

View file

@ -251,6 +251,7 @@ delete_fluid_ramsfont (fluid_ramsfont_t* sfont)
{
fluid_list_t *list;
fluid_rampreset_t* preset;
fluid_return_if_fail(sfont != NULL);
/* Check that no samples are currently used */
for (list = sfont->sample; list; list = fluid_list_next(list)) {
@ -534,25 +535,21 @@ new_fluid_rampreset(fluid_ramsfont_t* sfont)
}
/* Delete a RAM SoundFont preset */
static int
static void
delete_fluid_rampreset (fluid_rampreset_t* preset)
{
int err = FLUID_OK;
fluid_preset_zone_t* zone;
fluid_rampreset_voice_t *data;
fluid_return_if_fail(preset != NULL);
if (preset->global_zone != NULL) {
if (delete_fluid_preset_zone(preset->global_zone) != FLUID_OK) {
err = FLUID_FAILED;
}
delete_fluid_preset_zone(preset->global_zone);
preset->global_zone = NULL;
}
zone = preset->zone;
while (zone != NULL) {
preset->zone = zone->next;
if (delete_fluid_preset_zone(zone) != FLUID_OK) {
err = FLUID_FAILED;
}
delete_fluid_preset_zone(zone) != FLUID_OK);
zone = preset->zone;
}
@ -570,7 +567,6 @@ delete_fluid_rampreset (fluid_rampreset_t* preset)
preset->presetvoices = NULL;
FLUID_FREE(preset);
return err;
}
/* Get a RAM SoundFont preset bank */
@ -1217,14 +1213,12 @@ new_fluid_ramsample (void)
* @param sample Sample to delete
* @return #FLUID_OK
*/
int
void
delete_fluid_ramsample (fluid_sample_t* sample)
{
fluid_return_if_fail(sample != NULL);
/* same as delete_fluid_sample, plus frees the data */
if (sample->data != NULL) {
FLUID_FREE(sample->data);
}
sample->data = NULL;
FLUID_FREE(sample);
return FLUID_OK;
}

View file

@ -75,9 +75,7 @@ new_fluid_event()
void
delete_fluid_event(fluid_event_t* evt)
{
if (evt == NULL) {
return;
}
fluid_return_if_fail(evt != NULL);
FLUID_FREE(evt);
}

View file

@ -94,11 +94,10 @@ fluid_tuning_duplicate (fluid_tuning_t *tuning)
void
delete_fluid_tuning (fluid_tuning_t *tuning)
{
if(tuning != NULL)
{
if (tuning->name) FLUID_FREE (tuning->name);
FLUID_FREE (tuning);
}
fluid_return_if_fail(tuning != NULL);
FLUID_FREE (tuning->name);
FLUID_FREE (tuning);
}
/* Add a reference to a tuning object */

View file

@ -220,9 +220,8 @@ new_fluid_voice(fluid_real_t output_rate)
int
delete_fluid_voice(fluid_voice_t* voice)
{
if (voice == NULL) {
return FLUID_OK;
}
fluid_return_val_if_fail(voice != NULL, FLUID_OK);
if (!voice->can_access_rvoice || !voice->can_access_overflow_rvoice) {
/* stop rvoice before deleting voice! */
return FLUID_FAILED;

View file

@ -745,9 +745,7 @@ void
delete_fluid_timer (fluid_timer_t *timer)
{
int auto_destroy;
if(timer == NULL)
return;
fluid_return_if_fail(timer != NULL);
auto_destroy = timer->auto_destroy;
@ -1092,8 +1090,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
void delete_fluid_server_socket(fluid_server_socket_t* server_socket)
{
if(server_socket == NULL)
return;
fluid_return_if_fail(server_socket != NULL);
server_socket->cont = 0;
if (server_socket->socket != INVALID_SOCKET) {
@ -1286,8 +1283,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
void delete_fluid_server_socket(fluid_server_socket_t *server_socket)
{
if(server_socket == NULL)
return;
fluid_return_if_fail(server_socket != NULL);
server_socket->cont = 0;

View file

@ -148,6 +148,7 @@ new_fluid_cond_mutex (void)
static FLUID_INLINE void
delete_fluid_cond_mutex (fluid_cond_mutex_t *m)
{
fluid_return_if_fail(m != NULL);
g_mutex_clear (m);
g_free (m);
}
@ -170,6 +171,7 @@ new_fluid_cond (void)
static FLUID_INLINE void
delete_fluid_cond (fluid_cond_t *cond)
{
fluid_return_if_fail(cond != NULL);
g_cond_clear (cond);
g_free (cond);
}