delete_*() refactorings in defsfont

This commit is contained in:
derselbst 2017-11-05 15:33:28 +01:00
parent 60121af287
commit 1b2a098c7c
2 changed files with 14 additions and 22 deletions

View file

@ -496,8 +496,7 @@ int delete_fluid_defsfont(fluid_defsfont_t* sfont)
fluid_defpreset_t* preset; fluid_defpreset_t* preset;
fluid_sample_t* sample; fluid_sample_t* sample;
if(sfont == NULL) fluid_return_val_if_fail(sfont != NULL, FLUID_OK);
return FLUID_OK;
/* Check that no samples are currently used */ /* Check that no samples are currently used */
for (list = sfont->sample; list; list = fluid_list_next(list)) { for (list = sfont->sample; list; list = fluid_list_next(list)) {
@ -620,8 +619,7 @@ int fluid_defsfont_load(fluid_defsfont_t* sfont, const char* file)
err_exit: err_exit:
sfont_close (sfdata); sfont_close (sfdata);
if (preset != NULL) delete_fluid_defpreset(preset);
delete_fluid_defpreset(preset);
return FLUID_FAILED; return FLUID_FAILED;
} }
@ -746,14 +744,12 @@ new_fluid_defpreset(fluid_defsfont_t* sfont)
/* /*
* delete_fluid_defpreset * delete_fluid_defpreset
*/ */
int void
delete_fluid_defpreset(fluid_defpreset_t* preset) delete_fluid_defpreset(fluid_defpreset_t* preset)
{ {
int err = FLUID_OK;
fluid_preset_zone_t* zone; fluid_preset_zone_t* zone;
if(preset == NULL) fluid_return_if_fail(preset != NULL);
return err;
delete_fluid_preset_zone(preset->global_zone); delete_fluid_preset_zone(preset->global_zone);
preset->global_zone = NULL; preset->global_zone = NULL;
@ -765,7 +761,6 @@ delete_fluid_defpreset(fluid_defpreset_t* preset)
zone = preset->zone; zone = preset->zone;
} }
FLUID_FREE(preset); FLUID_FREE(preset);
return err;
} }
int int
@ -1168,8 +1163,7 @@ delete_fluid_preset_zone(fluid_preset_zone_t* zone)
{ {
fluid_mod_t *mod, *tmp; fluid_mod_t *mod, *tmp;
if(zone == NULL) fluid_return_if_fail(zone != NULL);
return;
mod = zone->mod; mod = zone->mod;
while (mod) /* delete the modulators */ while (mod) /* delete the modulators */
@ -1179,8 +1173,8 @@ delete_fluid_preset_zone(fluid_preset_zone_t* zone)
fluid_mod_delete (tmp); fluid_mod_delete (tmp);
} }
if (zone->name) FLUID_FREE (zone->name); FLUID_FREE (zone->name);
if (zone->inst) delete_fluid_inst (zone->inst); delete_fluid_inst (zone->inst);
FLUID_FREE(zone); FLUID_FREE(zone);
} }
@ -1402,11 +1396,12 @@ new_fluid_inst()
/* /*
* delete_fluid_inst * delete_fluid_inst
*/ */
int void
delete_fluid_inst(fluid_inst_t* inst) delete_fluid_inst(fluid_inst_t* inst)
{ {
fluid_inst_zone_t* zone; fluid_inst_zone_t* zone;
int err = FLUID_OK;
fluid_return_if_fail(inst != NULL);
delete_fluid_inst_zone(inst->global_zone); delete_fluid_inst_zone(inst->global_zone);
inst->global_zone = NULL; inst->global_zone = NULL;
@ -1418,7 +1413,6 @@ delete_fluid_inst(fluid_inst_t* inst)
zone = inst->zone; zone = inst->zone;
} }
FLUID_FREE(inst); FLUID_FREE(inst);
return err;
} }
/* /*
@ -1561,8 +1555,7 @@ delete_fluid_inst_zone(fluid_inst_zone_t* zone)
{ {
fluid_mod_t *mod, *tmp; fluid_mod_t *mod, *tmp;
if(zone == NULL) fluid_return_if_fail(zone != NULL);
return;
mod = zone->mod; mod = zone->mod;
while (mod) /* delete the modulators */ while (mod) /* delete the modulators */
@ -1807,8 +1800,7 @@ new_fluid_sample()
void void
delete_fluid_sample(fluid_sample_t* sample) delete_fluid_sample(fluid_sample_t* sample)
{ {
if(sample == NULL) fluid_return_if_fail(sample != NULL);
return;
if (sample->sampletype & FLUID_SAMPLETYPE_OGG_VORBIS) if (sample->sampletype & FLUID_SAMPLETYPE_OGG_VORBIS)
{ {

View file

@ -416,7 +416,7 @@ struct _fluid_defpreset_t
}; };
fluid_defpreset_t* new_fluid_defpreset(fluid_defsfont_t* sfont); fluid_defpreset_t* new_fluid_defpreset(fluid_defsfont_t* sfont);
int delete_fluid_defpreset(fluid_defpreset_t* preset); void delete_fluid_defpreset(fluid_defpreset_t* preset);
fluid_defpreset_t* fluid_defpreset_next(fluid_defpreset_t* preset); fluid_defpreset_t* fluid_defpreset_next(fluid_defpreset_t* preset);
int fluid_defpreset_import_sfont(fluid_defpreset_t* preset, SFPreset* sfpreset, fluid_defsfont_t* sfont); int fluid_defpreset_import_sfont(fluid_defpreset_t* preset, SFPreset* sfpreset, fluid_defsfont_t* sfont);
int fluid_defpreset_set_global_zone(fluid_defpreset_t* preset, fluid_preset_zone_t* zone); int fluid_defpreset_set_global_zone(fluid_defpreset_t* preset, fluid_preset_zone_t* zone);
@ -462,7 +462,7 @@ struct _fluid_inst_t
}; };
fluid_inst_t* new_fluid_inst(void); fluid_inst_t* new_fluid_inst(void);
int delete_fluid_inst(fluid_inst_t* inst); void delete_fluid_inst(fluid_inst_t* inst);
int fluid_inst_import_sfont(fluid_inst_t* inst, SFInst *sfinst, fluid_defsfont_t* sfont); int fluid_inst_import_sfont(fluid_inst_t* inst, SFInst *sfinst, fluid_defsfont_t* sfont);
int fluid_inst_set_global_zone(fluid_inst_t* inst, fluid_inst_zone_t* zone); int fluid_inst_set_global_zone(fluid_inst_t* inst, fluid_inst_zone_t* zone);
int fluid_inst_add_zone(fluid_inst_t* inst, fluid_inst_zone_t* zone); int fluid_inst_add_zone(fluid_inst_t* inst, fluid_inst_zone_t* zone);