Mercurial > otakunoraifu
changeset 7:fa8511a21d05
Fixes somes memory leaks
| author | thib |
|---|---|
| date | Tue, 05 Aug 2008 10:06:04 +0000 |
| parents | 2c890434e30f |
| children | 55b577e5f5b5 |
| files | font/font_face.cc music2/koedec_ogg.cc music2/music.cc music2/wavfile.cc system/file.cc |
| diffstat | 5 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/font/font_face.cc +++ b/font/font_face.cc @@ -71,6 +71,7 @@ #endif } } + delete[] name; return; }
--- a/music2/koedec_ogg.cc +++ b/music2/koedec_ogg.cc @@ -101,8 +101,12 @@ int ogg_get_rate(FILE *stream) { OggVorbis_File vf; - ov_open(stream, &vf, NULL, 0); - return vf.vi->rate; + ov_callbacks callback(OV_CALLBACKS_DEFAULT); + callback.close_func = NULL; + ov_test_callbacks(stream, &vf, NULL, 0, callback); + int rate = vf.vi->rate; + ov_clear(&vf); + return rate; } extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) {
--- a/music2/music.cc +++ b/music2/music.cc @@ -220,6 +220,7 @@ memcpy(stream_dup, stream, len); memset(stream, 0, len); SDL_MixAudio(stream, (Uint8*)stream_dup, len, cur_vol); + delete[] stream_dup; return; } @@ -290,7 +291,7 @@ } if (playing_koedata) { - delete[] playing_koedata; + free(playing_koedata); playing_koedata = 0; }
--- a/music2/wavfile.cc +++ b/music2/wavfile.cc @@ -352,7 +352,7 @@ static int conv_wave_rate(short* in_buf, int length, int in_rate, int out_rate, char* tmpbuf); WAVFILE_Converter::~WAVFILE_Converter() { if (cvt) { - if (cvt->buf) delete cvt->buf; + if (cvt->buf) delete[] cvt->buf; delete cvt; cvt = 0; }
