[Scummvm-cvs-logs] SF.net SVN: scummvm:[45208] scummvm/trunk/engines/kyra/sound_towns.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun Oct 18 00:47:42 CEST 2009
Revision: 45208
http://scummvm.svn.sourceforge.net/scummvm/?rev=45208&view=rev
Author: lordhoto
Date: 2009-10-17 22:47:42 +0000 (Sat, 17 Oct 2009)
Log Message:
-----------
Fix memory leak.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/sound_towns.cpp
Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp 2009-10-17 22:47:21 UTC (rev 45207)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp 2009-10-17 22:47:42 UTC (rev 45208)
@@ -1622,13 +1622,22 @@
void generateOutput(int32 &leftSample, int32 &rightSample, int32 *del, int32 *feed);
struct ChanInternal {
+ ChanInternal() {
+ memset(this, 0, sizeof(ChanInternal));
+ }
+
+ ~ChanInternal() {
+ for (uint i = 0; i < ARRAYSIZE(opr); ++i)
+ delete opr[i];
+ }
+
uint16 frqTemp;
bool enableLeft;
bool enableRight;
bool updateEnvelopeParameters;
int32 feedbuf[3];
uint8 algorithm;
- TownsPC98_OpnOperator **opr;
+ TownsPC98_OpnOperator *opr[4];
};
TownsPC98_OpnSquareSineSource *_ssg;
@@ -2915,7 +2924,7 @@
_mixer(mixer),
_chanInternal(0), _ssg(0), _prc(0),
_numChan(type == OD_TYPE26 ? 3 : 6), _numSSG(type == OD_TOWNS ? 0 : 3), _hasPercussion(type == OD_TYPE86 ? true : false),
- _oprRates(0), _oprRateshift(0), _oprAttackDecay(0), _oprFrq(0), _oprSinTbl(0), _oprLevelOut(0), _oprDetune(0),
+ _oprRates(0), _oprRateshift(0), _oprAttackDecay(0), _oprFrq(0), _oprSinTbl(0), _oprLevelOut(0), _oprDetune(0),
_baserate(55125.0f / (float)mixer->getOutputRate()),
_regProtectionFlag(false), _ready(false) {
@@ -2950,14 +2959,11 @@
generateTables();
- TownsPC98_OpnOperator **opr = new TownsPC98_OpnOperator*[_numChan << 2];
- for (int i = 0; i < (_numChan << 2); i++)
- opr[i] = new TownsPC98_OpnOperator(_timerbase, _oprRates, _oprRateshift, _oprAttackDecay, _oprFrq, _oprSinTbl, _oprLevelOut, _oprDetune);
-
_chanInternal = new ChanInternal[_numChan];
for (int i = 0; i < _numChan; i++) {
memset(&_chanInternal[i], 0, sizeof(ChanInternal));
- _chanInternal[i].opr = &opr[i << 2];
+ for (int j = 0; j < 4; ++j)
+ _chanInternal[i].opr[j] = new TownsPC98_OpnOperator(_timerbase, _oprRates, _oprRateshift, _oprAttackDecay, _oprFrq, _oprSinTbl, _oprLevelOut, _oprDetune);
}
if (_numSSG) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list