Implemented the SciGuiView destructor and plugged a memory leak in the current GUI

svn-id: r44740
This commit is contained in:
Filippos Karapetis 2009-10-07 17:29:37 +00:00
parent 94a9616d90
commit 6e17b025a5
2 changed files with 11 additions and 1 deletions

View File

@ -554,7 +554,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
curCel->index_data = (byte *)malloc(celInfo->width * celInfo->height);
byte *tmpBuffer = guiView->getBitmap(i, j);
memcpy(curCel->index_data, tmpBuffer, celInfo->width * celInfo->height);
delete tmpBuffer;
curCel->flags = 0;
curCel->width = celInfo->width;
curCel->height = celInfo->height;
@ -569,6 +568,8 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
}
}
delete guiView;
if (!res) {
res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->scaled_data.view = NULL;

View File

@ -40,6 +40,15 @@ SciGuiView::SciGuiView(ResourceManager *resMan, SciGuiScreen *screen, SciGuiPale
}
SciGuiView::~SciGuiView() {
// Iterate through the loops
for (uint16 loopNum = 0; loopNum < _loopCount; loopNum++) {
// and through the cells of each loop
for (uint16 celNum = 0; celNum < _loop[loopNum].celCount; celNum++) {
delete _loop[loopNum].cel[celNum].rawBitmap;
}
delete _loop[loopNum].cel;
}
delete _loop;
}
static const byte EGAMappingDefault[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };