aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-02 20:32:06 +0100
committerWillem Jan Palenstijn2015-12-23 21:33:47 +0100
commit69bdfae23586a4a03197d0e7b6a722068538ff2f (patch)
tree956c87ddf04a9918e1427d88a0b851bc86d36b83
parentadbb0ce0c52e2a9f0f6c52adf1d83bf351e8e1fb (diff)
downloadscummvm-rg350-69bdfae23586a4a03197d0e7b6a722068538ff2f.tar.gz
scummvm-rg350-69bdfae23586a4a03197d0e7b6a722068538ff2f.tar.bz2
scummvm-rg350-69bdfae23586a4a03197d0e7b6a722068538ff2f.zip
LAB: Plug memory leak
-rw-r--r--engines/lab/engine.cpp16
-rw-r--r--engines/lab/lab.cpp2
-rw-r--r--engines/lab/lab.h1
-rw-r--r--engines/lab/labsets.cpp2
4 files changed, 19 insertions, 2 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1823fe6fa5..19948270fb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -309,6 +309,20 @@ bool LabEngine::setUpScreens() {
return true;
}
+void LabEngine::freeScreens() {
+ for (uint16 i = 0; i < 20; i++)
+ delete _moveImages[i];
+
+ if (getPlatform() == Common::kPlatformWindows) {
+ for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+ delete _invImages[imgIdx];
+ } else {
+ for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+ delete _invImages[imgIdx];
+ }
+}
+
+
/******************************************************************************/
/* Permanently flips the imagery of a gadget. */
/******************************************************************************/
@@ -1302,6 +1316,8 @@ void LabEngine::go() {
freeRoomBuffer();
freeBuffer();
+ freeScreens();
+
_music->freeMusic();
}
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1c95746857..ba5efecd2c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -94,7 +94,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
for (int i = 0; i < 20; i++)
_moveImages[20] = nullptr;
-
+
for (int i = 0; i < 10; i++)
_invImages[10] = nullptr;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 6135f5e9d7..d49481548e 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -190,6 +190,7 @@ private:
// engine.cpp
bool setUpScreens();
+ void freeScreens();
void perFlipGadget(uint16 gadID);
bool doCloseUp(CloseDataPtr cptr);
void mainGameLoop();
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 2ab9abfe4a..21c495d246 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -34,7 +34,7 @@
namespace Lab {
- LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
+LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
last = (((last + 15) >> 4) << 4);
_array = (uint16 *)calloc(last >> 3, 2);