diff options
author | Paul Gilbert | 2014-02-19 21:56:38 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-02-19 21:56:38 -0500 |
commit | 488bf66c3e451a65ab14a387f681fb91aa5c6253 (patch) | |
tree | 9f7e1d5afb1ae4f98c4637cb596b8085e8025936 | |
parent | 1b0c1b3f561576cbcd7c1494d3893200442dace4 (diff) | |
download | scummvm-rg350-488bf66c3e451a65ab14a387f681fb91aa5c6253.tar.gz scummvm-rg350-488bf66c3e451a65ab14a387f681fb91aa5c6253.tar.bz2 scummvm-rg350-488bf66c3e451a65ab14a387f681fb91aa5c6253.zip |
MADS: Fix memory leaks in MSurface
-rw-r--r-- | engines/mads/msurface.cpp | 15 | ||||
-rw-r--r-- | engines/mads/msurface.h | 9 |
2 files changed, 18 insertions, 6 deletions
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index e7cc08e636..f71a4a7a4e 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -51,16 +51,27 @@ MSurface *MSurface::init(int width, int height) { } } -MSurface::MSurface(bool isScreen) { +MSurface::MSurface(bool isScreen) { + pixels = nullptr; setSize(g_system->getWidth(), g_system->getHeight()); _isScreen = isScreen; } MSurface::MSurface(int width, int height) { + pixels = nullptr; setSize(width, height); _isScreen = false; } +MSurface::~MSurface() { + Graphics::Surface::free(); +} + +void MSurface::setSize(int width, int height) { + Graphics::Surface::free(); + Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); +} + void MSurface::vLine(int x, int y1, int y2) { Graphics::Surface::vLine(x, y1, y2, _color); } @@ -271,7 +282,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo } void MSurface::empty() { - Common::fill(getBasePtr(0, 0), getBasePtr(w, h), _vm->_palette->BLACK); + Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK); } void MSurface::frameRect(const Common::Rect &r, uint8 color) { diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index fe6d1f22b4..42c56e9393 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -87,14 +87,15 @@ public: */ static int scaleValue(int value, int scale, int err); public: - virtual ~MSurface() {} + /** + * Destructor + */ + virtual ~MSurface(); /** * Reinitialises a surface to have a given set of dimensions */ - void setSize(int width, int height) { - Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - } + void setSize(int width, int height); /** * Sets the color used for drawing on the surface |