TONY: Fix some Valgrind identified memory leaks

This commit is contained in:
Paul Gilbert 2012-05-05 10:56:56 +10:00
parent 734fae9193
commit 046620054f
5 changed files with 30 additions and 2 deletions

View File

@ -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;
}

View File

@ -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; }

View File

@ -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);

View File

@ -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);

View File

@ -410,6 +410,7 @@ void TonyEngine::Close(void) {
CloseMusic();
CloseHandle(m_hEndOfFrame);
_theBoxes.Close();
RMText::Unload();
_theEngine.Close();
m_wnd.Close();
}