- plugged the pending memory leaks.

This commit is contained in:
Christoph Oelckers 2018-02-21 21:33:56 +01:00
parent 5219916de5
commit e84ec2978a
5 changed files with 15 additions and 24 deletions

View file

@ -118,8 +118,12 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args)
if (instruments != nullptr && !instruments->checkConfig(args))
{
delete instruments;
instruments = nullptr;
}
if (instruments == nullptr)
{
instruments = new TimidityPlus::Instruments;
}
instruments = new TimidityPlus::Instruments;
if (!instruments->load(args))
{
delete instruments;

View file

@ -1867,15 +1867,13 @@ Instrument *Instruments::play_midi_load_instrument(int dr, int bk, int prog, boo
void Instruments::init_userdrum()
{
int i;
AlternateAssign *alt;
free_userdrum();
for (i = 0; i<2; i++) { /* allocate alternative assign */
alt = (AlternateAssign *)safe_malloc(sizeof(AlternateAssign));
memset(alt, 0, sizeof(AlternateAssign));
memset(&alt[i], 0, sizeof(AlternateAssign));
alloc_instrument_bank(1, 64 + i);
drumset[64 + i]->alt = alt;
drumset[64 + i]->alt = &alt[i];
}
}

View file

@ -319,6 +319,7 @@ class Instruments
UserDrumset *userdrum_first = (UserDrumset *)NULL;
UserDrumset *userdrum_last = (UserDrumset *)NULL;
AlternateAssign alt[2];
/* Some functions get aggravated if not even the standard banks are available. */
ToneBank

View file

@ -5779,11 +5779,6 @@ struct midi_file_info *Player::new_midi_file_info()
return p;
}
struct midi_file_info *Player::get_midi_file_info(const char *filename, int newp)
{
return &midifileinfo;
}
/*
@ -5799,21 +5794,18 @@ void Player::playmidi_stream_init(void)
CLEAR_CHANNELMASK(channel_mute);
if (temper_type_mute & 1)
FILL_CHANNELMASK(channel_mute);
if(first)
{
first = 0;
init_mblock(&playmidi_pool);
current_file_info = get_midi_file_info("TiMidity", 1);
midi_streaming=1;
}
if (first)
{
first = 0;
init_mblock(&playmidi_pool);
midi_streaming = 1;
}
else
reuse_mblock(&playmidi_pool);
/* Fill in current_file_info */
current_file_info = get_midi_file_info("", 0);
current_file_info = &midifileinfo;
current_file_info->readflag = 1;
current_file_info->seq_name = safe_strdup("TiMidity server");
current_file_info->karaoke_title = current_file_info->first_text = NULL;
current_file_info->hdrsiz = 0;
current_file_info->format = 0;
current_file_info->tracks = 0;

View file

@ -490,9 +490,6 @@ enum {
struct midi_file_info
{
int readflag;
char *seq_name;
char *karaoke_title;
char *first_text;
int16_t hdrsiz;
int16_t format;
int16_t tracks;
@ -723,7 +720,6 @@ public:
void free_drum_effect(int);
void change_system_mode(int mode);
struct midi_file_info *get_midi_file_info(const char *filename, int newp);
void recompute_freq(int v);
int get_default_mapID(int ch);
void init_channel_layer(int ch);