[Scummvm-cvs-logs] SF.net SVN: scummvm:[55363] scummvm/trunk/engines/hugo
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Thu Jan 20 23:31:05 CET 2011
Revision: 55363
http://scummvm.svn.sourceforge.net/scummvm/?rev=55363&view=rev
Author: tdhs
Date: 2011-01-20 22:31:05 +0000 (Thu, 20 Jan 2011)
Log Message:
-----------
HUGO: Close Memory Leak in TopMenu Surfaces.
Modified Paths:
--------------
scummvm/trunk/engines/hugo/menu.cpp
scummvm/trunk/engines/hugo/menu.h
Modified: scummvm/trunk/engines/hugo/menu.cpp
===================================================================
--- scummvm/trunk/engines/hugo/menu.cpp 2011-01-20 21:35:00 UTC (rev 55362)
+++ scummvm/trunk/engines/hugo/menu.cpp 2011-01-20 22:31:05 UTC (rev 55363)
@@ -57,11 +57,21 @@
kCmdInvent = 'INVT'
};
-TopMenu::TopMenu(HugoEngine *vm) : Dialog(0, 0, kMenuWidth, kMenuHeight), arrayBmp(0),
+TopMenu::TopMenu(HugoEngine *vm) : Dialog(0, 0, kMenuWidth, kMenuHeight), arrayBmp(0), arraySize(0),
_vm(vm) {
init();
}
+TopMenu::~TopMenu() {
+ for (int i = 0; i < arraySize; i++) {
+ arrayBmp[i * 2]->free();
+ delete arrayBmp[i * 2];
+ arrayBmp[i * 2 + 1]->free();
+ delete arrayBmp[i * 2 + 1];
+ }
+ delete[] arrayBmp;
+}
+
void TopMenu::init() {
int x = kMenuX;
int y = kMenuY;
@@ -78,7 +88,6 @@
}
void TopMenu::reflowLayout() {
-
_w = g_system->getOverlayWidth();
int scale = (_w > 320 ? 2 : 1);
@@ -134,9 +143,10 @@
}
void TopMenu::loadBmpArr(Common::File &in) {
- uint16 arraySize = in.readUint16BE();
+ arraySize = in.readUint16BE();
- arrayBmp = (Graphics::Surface **)malloc(sizeof(Graphics::Surface *) * (arraySize * 2));
+ delete arrayBmp;
+ arrayBmp = new Graphics::Surface *[arraySize * 2];
for (int i = 0; i < arraySize; i++) {
uint16 bmpSize = in.readUint16BE();
uint32 filPos = in.pos();
Modified: scummvm/trunk/engines/hugo/menu.h
===================================================================
--- scummvm/trunk/engines/hugo/menu.h 2011-01-20 21:35:00 UTC (rev 55362)
+++ scummvm/trunk/engines/hugo/menu.h 2011-01-20 22:31:05 UTC (rev 55363)
@@ -45,6 +45,7 @@
class TopMenu : public GUI::Dialog {
public:
TopMenu(HugoEngine *vm);
+ ~TopMenu();
void reflowLayout();
void handleCommand(GUI::CommandSender *sender, uint32 command, uint32 data);
@@ -68,7 +69,7 @@
GUI::PicButtonWidget *_inventButton;
Graphics::Surface **arrayBmp;
-
+ uint16 arraySize;
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list