From 62ff56804c34aaaf2741fea33eee5d681a9a28b4 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 21 Sep 2004 12:29:02 +0000 Subject: Fix memory leak svn-id: r15221 --- scumm/sound.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 77c595a42e..735b287cf2 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -216,7 +216,7 @@ void Sound::playSound(int soundID, int offset) { } musicFile.seek(music_offs, SEEK_SET); - ptr = (byte *) calloc(size, 1); + ptr = (byte *)malloc(size); musicFile.read(ptr, size); musicFile.close(); @@ -224,11 +224,8 @@ void Sound::playSound(int soundID, int offset) { music = true; if (_vm->_heversion == 70) { // Allocate a sound buffer, copy the data into it, and play - sound = (char *)malloc(size); - memcpy(sound, ptr, size); - free(ptr); _vm->_mixer->stopHandle(_musicChannelHandle); - _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, 11025, flags, soundID); + _vm->_mixer->playRaw(&_musicChannelHandle, ptr, size, 11025, flags, soundID); return; } } else { @@ -766,7 +763,7 @@ int Sound::isSoundRunning(int sound) const { } else if (sound == -1 || sound == 10000) { // getSoundStatus(), with a -1, will return the // ID number of the first active music it finds. - if (_vm->_heversion >= 70 || _currentMusic) + if (_vm->_heversion >= 70 || _currentMusic) return (_musicChannelHandle.isActive()) ? 1 : 0; else if (_vm->_imuse) return (_vm->_imuse->getSoundStatus(sound)); -- cgit v1.2.3