[Scummvm-cvs-logs] SF.net SVN: scummvm:[44413] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Sun Sep 27 20:11:06 CEST 2009
Revision: 44413
http://scummvm.svn.sourceforge.net/scummvm/?rev=44413&view=rev
Author: spalek
Date: 2009-09-27 18:11:06 +0000 (Sun, 27 Sep 2009)
Log Message:
-----------
Remove memory leak in animation manager. Get rid of 1 non-const reference parameter.
Modified Paths:
--------------
scummvm/trunk/engines/draci/animation.cpp
scummvm/trunk/engines/draci/animation.h
scummvm/trunk/engines/draci/script.cpp
scummvm/trunk/engines/draci/script.h
Modified: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp 2009-09-27 17:18:30 UTC (rev 44412)
+++ scummvm/trunk/engines/draci/animation.cpp 2009-09-27 18:11:06 UTC (rev 44413)
@@ -501,12 +501,12 @@
// Iterate for the first time to delete the animation
for (it = _animations.begin(); it != _animations.end(); ++it) {
if ((*it)->getID() == id) {
- (*it)->deleteFrames();
- _animations.erase(it);
-
// Remember index of the deleted animation
index = (*it)->getIndex();
+ delete *it;
+ _animations.erase(it);
+
debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", id);
break;
@@ -532,7 +532,7 @@
for (it = _animations.begin(); it != _animations.end(); ++it) {
if ((*it)->getID() == kOverlayImage) {
- (*it)->deleteFrames();
+ delete *it;
_animations.erase(it);
}
}
@@ -545,7 +545,7 @@
Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
- (*it)->deleteFrames();
+ delete *it;
}
_animations.clear();
@@ -566,7 +566,7 @@
debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", (*it)->getID());
- (*it)->deleteFrames();
+ delete *it;
_animations.erase(it);
}
}
Modified: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/trunk/engines/draci/animation.h 2009-09-27 17:18:30 UTC (rev 44412)
+++ scummvm/trunk/engines/draci/animation.h 2009-09-27 18:11:06 UTC (rev 44413)
@@ -79,7 +79,6 @@
void setCurrentFrame(uint frame);
uint currentFrameNum() const;
uint getFrameCount() const;
- void deleteFrames();
bool isPlaying() const;
void setPlaying(bool playing);
@@ -114,6 +113,7 @@
private:
uint nextFrameNum() const;
+ void deleteFrames();
/** Internal animation ID
* (as specified in the data files and the bytecode)
@@ -138,6 +138,9 @@
bool _playing;
bool _looping;
bool _paused;
+
+ /** Array of frames of the animation. The animation object owns these pointers.
+ */
Common::Array<Drawable*> _frames;
AnimationCallback _callback;
@@ -180,6 +183,10 @@
void insertAnimation(Animation *anim);
DraciEngine *_vm;
+
+ /** List of animation objects, maintained sorted by decreasing Z-coordinates.
+ * The animation manager owns the pointers.
+ */
Common::List<Animation *> _animations;
/** The index of the most recently added animation.
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2009-09-27 17:18:30 UTC (rev 44412)
+++ scummvm/trunk/engines/draci/script.cpp 2009-09-27 18:11:06 UTC (rev 44413)
@@ -799,7 +799,7 @@
* @param reader Stream reader set to the beginning of the expression
*/
-int Script::handleMathExpression(Common::MemoryReadStream &reader) const {
+int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
Common::Stack<int> stk;
mathExpressionObject obj;
GPL2Operator oper;
@@ -808,7 +808,7 @@
debugC(4, kDraciBytecodeDebugLevel, "\t<MATHEXPR>");
// Read in initial math object
- obj = (mathExpressionObject)reader.readSint16LE();
+ obj = (mathExpressionObject)reader->readSint16LE();
int value;
int arg1, arg2, res;
@@ -827,13 +827,13 @@
// If the object type is not known, assume that it's a number
default:
case kMathNumber:
- value = reader.readSint16LE();
+ value = reader->readSint16LE();
stk.push(value);
debugC(4, kDraciBytecodeDebugLevel, "\t\tnumber: %d", value);
break;
case kMathOperator:
- value = reader.readSint16LE();
+ value = reader->readSint16LE();
arg2 = stk.pop();
arg1 = stk.pop();
@@ -851,7 +851,7 @@
break;
case kMathVariable:
- value = reader.readSint16LE() - 1;
+ value = reader->readSint16LE() - 1;
stk.push(_vm->_game->getVariable(value));
@@ -860,7 +860,7 @@
break;
case kMathFunctionCall:
- value = reader.readSint16LE();
+ value = reader->readSint16LE();
// Fetch function
func = _functionList[value-1];
@@ -890,7 +890,7 @@
break;
}
- obj = (mathExpressionObject) reader.readSint16LE();
+ obj = (mathExpressionObject) reader->readSint16LE();
}
return stk.pop();
@@ -923,7 +923,7 @@
debugC(4, kDraciBytecodeDebugLevel,
"Evaluating (standalone) GPL expression at offset %d:", offset);
- return (bool)handleMathExpression(reader);
+ return (bool)handleMathExpression(&reader);
}
/**
@@ -1053,7 +1053,7 @@
if (cmd->_paramTypes[i] == 4) {
debugC(3, kDraciBytecodeDebugLevel,
"Evaluating (in-script) GPL expression at offset %d: ", offset);
- params.push(handleMathExpression(reader));
+ params.push(handleMathExpression(&reader));
}
else {
tmp = reader.readSint16LE();
Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h 2009-09-27 17:18:30 UTC (rev 44412)
+++ scummvm/trunk/engines/draci/script.h 2009-09-27 18:11:06 UTC (rev 44413)
@@ -167,7 +167,7 @@
void setupCommandList();
const GPL2Command *findCommand(byte num, byte subnum) const;
- int handleMathExpression(Common::MemoryReadStream &reader) const;
+ int handleMathExpression(Common::MemoryReadStream *reader) const;
DraciEngine *_vm;
};
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