aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-05-05 10:32:43 +1000
committerPaul Gilbert2012-05-05 10:32:43 +1000
commit734fae9193fdabd6dcac5f40f765d904c030f7d1 (patch)
tree4dfa6f2a449da5b054c43be2c0e331bb490f4a6e /engines
parent91328fce56144caf15abc8995b68a5a5a0562f0a (diff)
downloadscummvm-rg350-734fae9193fdabd6dcac5f40f765d904c030f7d1.tar.gz
scummvm-rg350-734fae9193fdabd6dcac5f40f765d904c030f7d1.tar.bz2
scummvm-rg350-734fae9193fdabd6dcac5f40f765d904c030f7d1.zip
TONY: Fixed some memory leaks identified by Valgrind
Diffstat (limited to 'engines')
-rw-r--r--engines/tony/gfxcore.cpp5
-rw-r--r--engines/tony/gfxengine.cpp3
-rw-r--r--engines/tony/inventory.cpp13
-rw-r--r--engines/tony/loc.cpp8
-rw-r--r--engines/tony/loc.h3
5 files changed, 27 insertions, 5 deletions
diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp
index 5737a6af45..de78b51a4e 100644
--- a/engines/tony/gfxcore.cpp
+++ b/engines/tony/gfxcore.cpp
@@ -709,11 +709,12 @@ void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) {
RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() {
alphaBlendColor = -1;
bNeedRLECompress = true;
+ m_buf = NULL;
}
RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() {
if (m_buf != NULL) {
- delete m_buf;
+ delete[] m_buf;
m_buf = NULL;
}
}
@@ -833,7 +834,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) {
// Ci copia l'immagine compressa
x = cur - MegaRLEBuf;
m_buf = new byte[x];
- CopyMemory(m_buf, MegaRLEBuf, x);
+ Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf);
}
void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp
index 6b5105bc35..7f2515af7b 100644
--- a/engines/tony/gfxengine.cpp
+++ b/engines/tony/gfxengine.cpp
@@ -78,11 +78,14 @@ RMGfxEngine::RMGfxEngine() {
// Crea il big buffer dove verranno disegnati i frame
m_bigBuf.Create(RM_BBX, RM_BBY, 16);
m_bigBuf.OffsetY(RM_SKIPY);
+
+ csMainLoop = NULL;
}
RMGfxEngine::~RMGfxEngine() {
// Chiude il buffer
m_bigBuf.Destroy();
+ g_system->deleteMutex(csMainLoop);
}
void RMGfxEngine::OpenOptionScreen(int type) {
diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp
index ade9c0eb34..50e4dd9411 100644
--- a/engines/tony/inventory.cpp
+++ b/engines/tony/inventory.cpp
@@ -63,6 +63,7 @@ RMInventory::RMInventory() {
m_state = CLOSED;
m_bCombining = false;
m_csModifyInterface = g_system->createMutex();
+ m_nItems = 0;
}
RMInventory::~RMInventory() {
@@ -94,7 +95,7 @@ void RMInventory::Init(void) {
// Nuovi oggetti
m_nItems = 78; // @@@ Numero di oggetti prendibili
- m_items = new RMInventoryItem[m_nItems+1];
+ m_items = new RMInventoryItem[m_nItems + 1];
curres = 10500;
@@ -114,14 +115,15 @@ void RMInventory::Init(void) {
ds.Close();
// Mette di default a pattern 1
- m_items[i].status=1;
+ m_items[i].pointer = NULL;
+ m_items[i].status = 1;
m_items[i].icon.SetPattern(1);
m_items[i].icon.DoFrame(this, false);
curres++;
if (i == 0 || i == 28 || i == 29) continue;
- m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()];
+ m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()];
for (j = 0; j < m_items[i].icon.NumPattern(); j++) {
RMResRaw raw(curres);
@@ -174,6 +176,11 @@ void RMInventory::Init(void) {
void RMInventory::Close(void) {
// Ciao memoria
if (m_items != NULL) {
+ // Delete the item pointers
+ for (int i = 0; i <= m_nItems; i++)
+ delete[] m_items[i].pointer;
+
+ // Delete the items array
delete[] m_items;
m_items = NULL;
}
diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp
index 62249da255..b5a233391a 100644
--- a/engines/tony/loc.cpp
+++ b/engines/tony/loc.cpp
@@ -1694,6 +1694,14 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) {
* RMBoxLoc Methods
\****************************************************************************/
+RMBoxLoc::RMBoxLoc() {
+ boxes = NULL;
+}
+
+RMBoxLoc::~RMBoxLoc() {
+ delete[] boxes;
+}
+
void RMBoxLoc::ReadFromStream(RMDataStream &ds) {
int i;
char buf[2];
diff --git a/engines/tony/loc.h b/engines/tony/loc.h
index c5c7859e73..c176367cd4 100644
--- a/engines/tony/loc.h
+++ b/engines/tony/loc.h
@@ -350,6 +350,9 @@ private:
void ReadFromStream(RMDataStream& ds);
public:
+ RMBoxLoc();
+ virtual ~RMBoxLoc();
+
friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl);
void RecalcAllAdj(void);
};