aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner2011-01-20 22:31:05 +0000
committerDavid Turner2011-01-20 22:31:05 +0000
commit5a7e25a3a64b4f383c4e0d585c82e1dee8297658 (patch)
treeaf3bec9e054cf54db87ed1ab696f6f9f19fae646
parentb10f072c9e735b85edc297d243b12ae50a9fb833 (diff)
downloadscummvm-rg350-5a7e25a3a64b4f383c4e0d585c82e1dee8297658.tar.gz
scummvm-rg350-5a7e25a3a64b4f383c4e0d585c82e1dee8297658.tar.bz2
scummvm-rg350-5a7e25a3a64b4f383c4e0d585c82e1dee8297658.zip
HUGO: Close Memory Leak in TopMenu Surfaces.
svn-id: r55363
-rw-r--r--engines/hugo/menu.cpp18
-rw-r--r--engines/hugo/menu.h3
2 files changed, 16 insertions, 5 deletions
diff --git a/engines/hugo/menu.cpp b/engines/hugo/menu.cpp
index d4962a9aca..f1dd281d12 100644
--- a/engines/hugo/menu.cpp
+++ b/engines/hugo/menu.cpp
@@ -57,11 +57,21 @@ enum {
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::init() {
}
void TopMenu::reflowLayout() {
-
_w = g_system->getOverlayWidth();
int scale = (_w > 320 ? 2 : 1);
@@ -134,9 +143,10 @@ void TopMenu::reflowLayout() {
}
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();
diff --git a/engines/hugo/menu.h b/engines/hugo/menu.h
index 33d5db7b79..03eb2ef0d8 100644
--- a/engines/hugo/menu.h
+++ b/engines/hugo/menu.h
@@ -45,6 +45,7 @@ enum MenuOption {
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 @@ protected:
GUI::PicButtonWidget *_inventButton;
Graphics::Surface **arrayBmp;
-
+ uint16 arraySize;
};
}