From 4b011b2f1cfdc3aac0468248f4feb9faea3501a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 17 Nov 2018 07:36:36 -0800 Subject: GLK: Freeing of data on exit --- engines/glk/selection.cpp | 11 +++++++++-- engines/glk/selection.h | 10 ++++++++++ engines/glk/windows.cpp | 4 ++++ engines/glk/windows.h | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/glk/selection.cpp b/engines/glk/selection.cpp index 566ae65345..f251171736 100644 --- a/engines/glk/selection.cpp +++ b/engines/glk/selection.cpp @@ -65,14 +65,21 @@ WindowMask::WindowMask() : _hor(0), _ver(0), _links(nullptr) { resize(g_system->getWidth(), g_system->getHeight()); } -void WindowMask::resize(size_t x, size_t y) { - // Deallocate old storage +WindowMask::~WindowMask() { + clear(); +} + +void WindowMask::clear() { for (size_t i = 0; i < _hor; i++) { if (_links[i]) delete _links[i]; } delete _links; +} + +void WindowMask::resize(size_t x, size_t y) { + clear(); _hor = x + 1; _ver = y + 1; diff --git a/engines/glk/selection.h b/engines/glk/selection.h index 4497d68539..10d6d5cdec 100644 --- a/engines/glk/selection.h +++ b/engines/glk/selection.h @@ -63,6 +63,11 @@ public: * Manages hyperlinks for the screen */ class WindowMask { +private: + /** + * Clear the links data + */ + void clear(); public: size_t _hor, _ver; glui32 **_links; @@ -74,6 +79,11 @@ public: */ WindowMask(); + /** + * Destructor + */ + ~WindowMask(); + /** * Resize the links array */ diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index 02298ad79e..ce1929fedf 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -70,6 +70,10 @@ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullpt _zcolor_Bright[0] = _zcolor_Bright[1] = _zcolor_Bright[2] = 0; } +Windows::~Windows() { + delete _rootWin; +} + Window *Windows::windowOpen(Window *splitwin, glui32 method, glui32 size, glui32 wintype, glui32 rock) { Window *newwin, *oldparent; diff --git a/engines/glk/windows.h b/engines/glk/windows.h index 98f0d2d6df..7abb9e5ff5 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -151,6 +151,11 @@ public: */ Windows(Graphics::Screen *screen); + /** + * Destructor + */ + ~Windows(); + /** * Open a new window */ -- cgit v1.2.3