aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
authorPaul Gilbert2012-05-05 10:56:56 +1000
committerPaul Gilbert2012-05-05 10:56:56 +1000
commit046620054f3b2817b366e3e3bc01b4a84206dd6f (patch)
tree911fc3725182760bc7b0ea0a9b325e4d0ab858bf /engines/tony
parent734fae9193fdabd6dcac5f40f765d904c030f7d1 (diff)
downloadscummvm-rg350-046620054f3b2817b366e3e3bc01b4a84206dd6f.tar.gz
scummvm-rg350-046620054f3b2817b366e3e3bc01b4a84206dd6f.tar.bz2
scummvm-rg350-046620054f3b2817b366e3e3bc01b4a84206dd6f.zip
TONY: Fix some Valgrind identified memory leaks
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/font.cpp12
-rw-r--r--engines/tony/font.h1
-rw-r--r--engines/tony/loc.cpp12
-rw-r--r--engines/tony/loc.h6
-rw-r--r--engines/tony/tony.cpp1
5 files changed, 30 insertions, 2 deletions
diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp
index 42540a2620..28e8f14d38 100644
--- a/engines/tony/font.cpp
+++ b/engines/tony/font.cpp
@@ -1829,6 +1829,18 @@ RMText::~RMText() {
}
+void RMText::Unload() {
+ if (m_fonts[0] != NULL) {
+ delete m_fonts[0];
+ delete m_fonts[1];
+ delete m_fonts[2];
+ delete m_fonts[3];
+ m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0;
+
+ g_system->unlockMutex(m_cs);
+ }
+}
+
void RMText::SetMaxLineLength(int max) {
maxLineLength = max;
}
diff --git a/engines/tony/font.h b/engines/tony/font.h
index 33332db9f0..3012502d4c 100644
--- a/engines/tony/font.h
+++ b/engines/tony/font.h
@@ -215,6 +215,7 @@ protected:
public:
RMText();
virtual ~RMText();
+ static void Unload();
// Setta il tipo di allineamento
void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; }
diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp
index b5a233391a..4bb1832102 100644
--- a/engines/tony/loc.cpp
+++ b/engines/tony/loc.cpp
@@ -1746,6 +1746,16 @@ RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) {
* RMGameBoxes methods
\****************************************************************************/
+RMGameBoxes::RMGameBoxes() {
+ m_nLocBoxes = 0;
+ Common::fill(m_allBoxes, m_allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL);
+}
+
+RMGameBoxes::~RMGameBoxes() {
+ for (int i = 1; i <= m_nLocBoxes; ++i)
+ delete m_allBoxes[i];
+}
+
void RMGameBoxes::Init(void) {
int i;
RMString fn;
@@ -1753,7 +1763,7 @@ void RMGameBoxes::Init(void) {
// Load boxes from disk
m_nLocBoxes = 130;
- for (i=1; i <= m_nLocBoxes; i++) {
+ for (i = 1; i <= m_nLocBoxes; i++) {
RMRes res(10000 + i);
ds.OpenBuffer(res);
diff --git a/engines/tony/loc.h b/engines/tony/loc.h
index c176367cd4..9ed1a284d1 100644
--- a/engines/tony/loc.h
+++ b/engines/tony/loc.h
@@ -357,13 +357,17 @@ public:
void RecalcAllAdj(void);
};
+#define GAME_BOXES_SIZE 200
class RMGameBoxes {
protected:
- RMBoxLoc *m_allBoxes[200];
+ RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE];
int m_nLocBoxes;
public:
+ RMGameBoxes();
+ ~RMGameBoxes();
+
void Init(void);
void Close(void);
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index 45545875e1..9ff306ca46 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -410,6 +410,7 @@ void TonyEngine::Close(void) {
CloseMusic();
CloseHandle(m_hEndOfFrame);
_theBoxes.Close();
+ RMText::Unload();
_theEngine.Close();
m_wnd.Close();
}