diff options
author | Lars Skovlund | 2011-02-02 21:05:38 +0000 |
---|---|---|
committer | Lars Skovlund | 2011-02-02 21:05:38 +0000 |
commit | 441c5e02111461e901f1f886f62e63f3afb131e3 (patch) | |
tree | e7e0a31982ef926e6946ebe990116a23d05b3c30 /engines | |
parent | b9b8b4d3eb9cdd280bf0c1162a93087e4cb8f876 (diff) | |
download | scummvm-rg350-441c5e02111461e901f1f886f62e63f3afb131e3.tar.gz scummvm-rg350-441c5e02111461e901f1f886f62e63f3afb131e3.tar.bz2 scummvm-rg350-441c5e02111461e901f1f886f62e63f3afb131e3.zip |
SCI: Fix memory leaks in GfxRobot
svn-id: r55740
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/graphics/robot.cpp | 14 | ||||
-rw-r--r-- | engines/sci/graphics/robot.h | 1 |
2 files changed, 10 insertions, 5 deletions
diff --git a/engines/sci/graphics/robot.cpp b/engines/sci/graphics/robot.cpp index c9191c6f8e..a058761cf8 100644 --- a/engines/sci/graphics/robot.cpp +++ b/engines/sci/graphics/robot.cpp @@ -68,10 +68,7 @@ GfxRobot::GfxRobot(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palet } GfxRobot::~GfxRobot() { - delete[] _resourceData; - delete[] _imageStart; - delete[] _audioStart; - delete[] _audioLen; + freeData(); } void GfxRobot::init(GuiResourceId resourceId, uint16 x, uint16 y) { @@ -174,6 +171,7 @@ void GfxRobot::drawNextFrame() { if (_curFrame == _frameCount) { // End of robot video, restore palette g_system->setPalette(_savedPal, 0, 256); + freeData(); _resourceId = -1; } } @@ -302,7 +300,13 @@ void GfxRobot::playAudio() { } } - +void GfxRobot::freeData() +{ + delete[] _resourceData; _resourceData = 0; + delete[] _imageStart; _imageStart = 0; + delete[] _audioStart; _audioStart = 0; + delete[] _audioLen; _audioLen = 0; +} #endif } // End of namespace Sci diff --git a/engines/sci/graphics/robot.h b/engines/sci/graphics/robot.h index f26ea84ad3..e5e1fa991d 100644 --- a/engines/sci/graphics/robot.h +++ b/engines/sci/graphics/robot.h @@ -51,6 +51,7 @@ private: void getFrameRect(int frame, Common::Rect &rect); // Not sure what to use this for yet int getFrameScale(int frame); // Scale factor (multiplied by 100). More like custom height, but why use a percentage for it? void setPalette(); + void freeData(); ResourceManager *_resMan; GfxScreen *_screen; |