From 5f8323bd50f958803107be6d64fa7dd9a9456bb7 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 14 Dec 2008 04:33:28 +0000 Subject: Plugging leaks svn-id: r35355 --- engines/gob/draw.cpp | 5 +++++ engines/gob/draw.h | 2 +- engines/gob/init.cpp | 5 ----- engines/gob/inter_v1.cpp | 7 ++----- engines/gob/inter_v5.cpp | 10 +++++----- engines/gob/util.cpp | 5 ----- engines/gob/util.h | 1 - engines/gob/video.cpp | 4 ++++ engines/gob/video.h | 8 ++++++-- engines/gob/video_v6.cpp | 6 +++++- 10 files changed, 28 insertions(+), 25 deletions(-) (limited to 'engines') diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 9b160d818c..3a63399efe 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -134,6 +134,11 @@ Draw::Draw(GobEngine *vm) : _vm(vm) { _scrollOffsetY = 0; } +Draw::~Draw() { + for (int i = 0; i < 8; i++) + delete _fonts[i]; +} + void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { if (_renderFlags & RENDERFLAG_NOINVALIDATE) { _vm->_video->dirtyRectsAll(); diff --git a/engines/gob/draw.h b/engines/gob/draw.h index cf1675f587..d1238bf702 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -168,7 +168,7 @@ public: virtual void spriteOperation(int16 operation) = 0; Draw(GobEngine *vm); - virtual ~Draw() {} + virtual ~Draw(); protected: GobEngine *_vm; diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp index 4fba74e02a..9820cc6774 100644 --- a/engines/gob/init.cpp +++ b/engines/gob/init.cpp @@ -209,11 +209,6 @@ void Init::initGame(const char *totName) { } - for (int i = 0; i < 4; i++) { - if (_vm->_draw->_fonts[i] != 0) - _vm->_util->freeFont(_vm->_draw->_fonts[i]); - } - delete _palDesc; _vm->_dataIO->closeDataFile(); _vm->_video->initPrimary(-1); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 3b371806ed..b250488dd2 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -2170,8 +2170,7 @@ bool Inter_v1::o1_loadFont(OpFuncParams ¶ms) { evalExpr(0); index = load16(); - if (_vm->_draw->_fonts[index]) - _vm->_util->freeFont(_vm->_draw->_fonts[index]); + delete _vm->_draw->_fonts[index]; _vm->_draw->animateCursor(4); if (_vm->_game->_extHandle >= 0) @@ -2189,9 +2188,7 @@ bool Inter_v1::o1_freeFont(OpFuncParams ¶ms) { int16 index; index = load16(); - if (_vm->_draw->_fonts[index]) - _vm->_util->freeFont(_vm->_draw->_fonts[index]); - + delete _vm->_draw->_fonts[index]; _vm->_draw->_fonts[index] = 0; return false; } diff --git a/engines/gob/inter_v5.cpp b/engines/gob/inter_v5.cpp index 58ded12434..0adef25667 100644 --- a/engines/gob/inter_v5.cpp +++ b/engines/gob/inter_v5.cpp @@ -852,7 +852,7 @@ void Inter_v5::o5_getSystemCDSpeed(OpGobParams ¶ms) { _vm->_draw->drawString("100 %", 402, 89, 112, 144, 0, _vm->_draw->_backSurface, font); _vm->_draw->forceBlit(); - _vm->_util->freeFont(font); + delete font; } } @@ -866,7 +866,7 @@ void Inter_v5::o5_getSystemRAM(OpGobParams ¶ms) { _vm->_draw->drawString("100 %", 402, 168, 112, 144, 0, _vm->_draw->_backSurface, font); _vm->_draw->forceBlit(); - _vm->_util->freeFont(font); + delete font; } } @@ -880,7 +880,7 @@ void Inter_v5::o5_getSystemCPUSpeed(OpGobParams ¶ms) { _vm->_draw->drawString("100 %", 402, 248, 112, 144, 0, _vm->_draw->_backSurface, font); _vm->_draw->forceBlit(); - _vm->_util->freeFont(font); + delete font; } } @@ -894,7 +894,7 @@ void Inter_v5::o5_getSystemDrawSpeed(OpGobParams ¶ms) { _vm->_draw->drawString("100 %", 402, 326, 112, 144, 0, _vm->_draw->_backSurface, font); _vm->_draw->forceBlit(); - _vm->_util->freeFont(font); + delete font; } } @@ -908,7 +908,7 @@ void Inter_v5::o5_totalSystemSpecs(OpGobParams ¶ms) { _vm->_draw->drawString("100 %", 402, 405, 112, 144, 0, _vm->_draw->_backSurface, font); _vm->_draw->forceBlit(); - _vm->_util->freeFont(font); + delete font; } } diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 52831637c1..e535505a87 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -378,11 +378,6 @@ Video::FontDesc *Util::loadFont(const char *path) { return fontDesc; } -void Util::freeFont(Video::FontDesc *fontDesc) { - delete[] (fontDesc->dataPtr - 4); - delete fontDesc; -} - void Util::insertStr(const char *str1, char *str2, int16 pos) { int len1 = strlen(str1); int len2 = strlen(str2); diff --git a/engines/gob/util.h b/engines/gob/util.h index 39ef16ceca..926338e271 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -77,7 +77,6 @@ public: void setScrollOffset(int16 x = -1, int16 y = -1); Video::FontDesc *loadFont(const char *path); - void freeFont(Video::FontDesc *fontDesc); static void insertStr(const char *str1, char *str2, int16 pos); static void cutFromStr(char *str, int16 from, int16 cutlen); diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 43fcb11bd5..fd256096ce 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -120,6 +120,10 @@ char Video::initDriver(int16 vidMode) { return 1; } +Video::~Video() { + delete _palLUT; +} + void Video::freeDriver() { delete _videoDriver; } diff --git a/engines/gob/video.h b/engines/gob/video.h index 37b3afb317..0afd2b31e2 100644 --- a/engines/gob/video.h +++ b/engines/gob/video.h @@ -75,7 +75,11 @@ public: int8 bitWidth; byte *extraData; FontDesc() : dataPtr(0), itemWidth(0), itemHeight(0), startItem(0), - endItem(0), itemSize(0), bitWidth(0) {} + endItem(0), itemSize(0), bitWidth(0) {} + ~FontDesc() { + if (dataPtr) + delete[] (dataPtr - 4); + } }; #define GDR_VERSION 4 @@ -177,7 +181,7 @@ public: virtual void init() { } Video(class GobEngine *vm); - virtual ~Video() {} + virtual ~Video(); protected: class VideoDriver *_videoDriver; diff --git a/engines/gob/video_v6.cpp b/engines/gob/video_v6.cpp index 76e0259ffd..c32b98d99f 100644 --- a/engines/gob/video_v6.cpp +++ b/engines/gob/video_v6.cpp @@ -27,6 +27,7 @@ #include "gob/gob.h" #include "gob/video.h" +#include "gob/util.h" #include "gob/indeo3.h" namespace Gob { @@ -40,10 +41,11 @@ void Video_v6::init() { initOSD(); char text[30]; - for (int i = 0; i < 64; i++) { + for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) { sprintf(text, "Building palette table: %02d/63", i); drawOSDText(text); _palLUT->buildNext(); + _vm->_util->processInput(); } } @@ -153,6 +155,8 @@ void Video_v6::drawYUV(SurfaceDesc *destDesc, int16 x, int16 y, dither->nextLine(); vidMem += destDesc->getWidth(); } + + delete dither; } const byte Video_v6::_ditherPalette[768] = { -- cgit v1.2.3