aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Page2008-08-14 00:26:57 +0000
committerChristopher Page2008-08-14 00:26:57 +0000
commit6bebff8ab0f6f7d440a83d7109ee46047085c5cc (patch)
tree09ef1890342bb7c8dc006eccc939a77c445b85e2
parent4f00562bb2a0343259caa8d276e351ed8f94baf2 (diff)
downloadscummvm-rg350-6bebff8ab0f6f7d440a83d7109ee46047085c5cc.tar.gz
scummvm-rg350-6bebff8ab0f6f7d440a83d7109ee46047085c5cc.tar.bz2
scummvm-rg350-6bebff8ab0f6f7d440a83d7109ee46047085c5cc.zip
Fixed a memory leak in Agos
svn-id: r33852
-rw-r--r--engines/agos/sound.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp
index c456c92e60..4d60bbdbed 100644
--- a/engines/agos/sound.cpp
+++ b/engines/agos/sound.cpp
@@ -56,10 +56,12 @@ protected:
public:
BaseSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false);
BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigEndian = false);
+ virtual ~BaseSound();
+ void close();
+
void playSound(uint sound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol = 0) {
playSound(sound, sound, type, handle, flags, vol);
}
- virtual ~BaseSound();
virtual void playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol = 0) = 0;
virtual Audio::AudioStream *makeAudioStream(uint sound) { return NULL; }
};
@@ -184,6 +186,12 @@ BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigE
_freeOffsets = false;
}
+void BaseSound::close() {
+ if (_freeOffsets) {
+ free(_offsets);
+ }
+}
+
BaseSound::~BaseSound() {
if (_freeOffsets)
free(_offsets);
@@ -555,6 +563,9 @@ void Sound::readSfxFile(const char *filename) {
void Sound::loadSfxTable(File *gameFile, uint32 base) {
stopAll();
+
+ if (_effects)
+ _effects->close();
if (_vm->getPlatform() == Common::kPlatformWindows)
_effects = new WavSound(_mixer, gameFile, base);