aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
authorPaul Gilbert2012-06-09 13:05:48 +1000
committerPaul Gilbert2012-06-09 13:05:48 +1000
commita50b1f32c1de667cd2d73535b07e62b000cf4483 (patch)
treef7be17ba266da83e17a7b637a550bd7a745ea626 /engines/tony
parent8d6f50463ee0541e2d4609f80443537adefdd35e (diff)
downloadscummvm-rg350-a50b1f32c1de667cd2d73535b07e62b000cf4483.tar.gz
scummvm-rg350-a50b1f32c1de667cd2d73535b07e62b000cf4483.tar.bz2
scummvm-rg350-a50b1f32c1de667cd2d73535b07e62b000cf4483.zip
TONY: Fixes for deallocating MPC and MPAL data
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/mpal/loadmpc.cpp12
-rw-r--r--engines/tony/mpal/mpal.cpp7
-rw-r--r--engines/tony/mpal/mpal.h4
-rw-r--r--engines/tony/tony.cpp1
4 files changed, 21 insertions, 3 deletions
diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp
index d0b6a75f72..1f610a8d2c 100644
--- a/engines/tony/mpal/loadmpc.cpp
+++ b/engines/tony/mpal/loadmpc.cpp
@@ -470,11 +470,17 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) {
*/
static void freeItem(LPMPALITEM lpmiItem) {
// Free the actions
- if (lpmiItem->Action)
+ if (lpmiItem->Action) {
+ for (int i = 0; i < lpmiItem->nActions; ++i) {
+ if (lpmiItem->Action[i].when != 0)
+ freeExpression(lpmiItem->Action[i].when);
+ }
+
globalDestroy(lpmiItem->Action);
+ }
// Free the commands
- for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i, ++lpmiItem) {
+ for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) {
if (lpmiItem->_command[i].type == 2) {
// Variable Assign
globalDestroy(lpmiItem->_command[i].lpszVarName);
@@ -715,7 +721,7 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) {
for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i)
globalFree(lpmdDialog->_periods[i]);
- for (i = 0; i < MAX_COMMANDS_PER_GROUP && (lpmdDialog->_command[i].type); i++) {
+ for (i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) {
if (lpmdDialog->_command[i].type == 2) {
// Variable assign
globalDestroy(lpmdDialog->_command[i].lpszVarName);
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index 04d562ffc9..4aac53bb8e 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -1548,6 +1548,13 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName,
return true;
}
+/**
+ * Frees resources allocated by the MPAL subsystem
+ */
+void mpalFree() {
+ // Free the resource list
+ globalDestroy(GLOBALS.lpResources);
+}
/**
* This is a general function to communicate with the library, to request information
diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h
index f23eaf8e4a..198083f851 100644
--- a/engines/tony/mpal/mpal.h
+++ b/engines/tony/mpal/mpal.h
@@ -402,6 +402,10 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION;
bool mpalInit(const char *lpszFileName, const char *lpszMprFileName,
LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings);
+/**
+ * Frees resources allocated by the MPAL subsystem
+ */
+void mpalFree();
/**
* This is a general function to communicate with the library, to request information
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index eab52c6b4b..a66e7b0684 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -573,6 +573,7 @@ void TonyEngine::close(void) {
_theBoxes.close();
_theEngine.close();
_window.close();
+ mpalFree();
FreeMpc();
delete[] _curThumbnail;
}