From 759203b3c4172ddedd0e446939d701d7e9389b11 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 3 May 2012 17:23:16 +0400 Subject: [PATCH 1/4] driver/volume.cpp: fix memleak - g_volscale re-created without delete --- src/driver/volume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp index f0e6d69c9..07f26ce78 100644 --- a/src/driver/volume.cpp +++ b/src/driver/volume.cpp @@ -105,7 +105,7 @@ void CVolume::Init() progress_h = std::max(icon_h, digit_h) - 2*pB; vbar_w += digit_w; } - + delete g_volscale; g_volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true); // mute icon From 73b09dd8321306c1e6cd37d7984b40e06998e374 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 3 May 2012 17:25:36 +0400 Subject: [PATCH 2/4] driver/fb_window.cpp: remove private_data, move its members to class; fix delete -> delete[] --- src/driver/fb_window.cpp | 32 +++++++++----------------------- src/driver/fb_window.h | 14 ++++++++------ 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/driver/fb_window.cpp b/src/driver/fb_window.cpp index 840550435..a39aa05e9 100644 --- a/src/driver/fb_window.cpp +++ b/src/driver/fb_window.cpp @@ -30,13 +30,6 @@ #include #include -class CPrivateData -{ - public: - CFrameBuffer * frameBuffer; - fb_pixel_t * Background; -}; - CFBWindow::CFBWindow(const int _x, const int _y, const int _dx, const int _dy) { x = _x ; @@ -44,35 +37,28 @@ CFBWindow::CFBWindow(const int _x, const int _y, const int _dx, const int _dy) dx = _dx; dy = _dy; - private_data = (void *) new CPrivateData; - ((CPrivateData *)private_data)->frameBuffer = CFrameBuffer::getInstance(); - ((CPrivateData *)private_data)->Background = new fb_pixel_t [_dx * _dy]; - if (((CPrivateData *)private_data)->Background != NULL) - ((CPrivateData *)private_data)->frameBuffer->SaveScreen(_x, _y, _dx, _dy, (fb_pixel_t *)((CPrivateData *)private_data)->Background); + frameBuffer = CFrameBuffer::getInstance(); + Background = new fb_pixel_t [_dx * _dy]; + if (Background != NULL) + frameBuffer->SaveScreen(_x, _y, _dx, _dy, Background); } CFBWindow::~CFBWindow(void) { - if (private_data != NULL) - { - if (((CPrivateData *)private_data)->Background != NULL) - ((CPrivateData *)private_data)->frameBuffer->RestoreScreen(x, y, dx, dy, (fb_pixel_t *)((CPrivateData *)private_data)->Background); - - delete ((CPrivateData *)private_data)->Background; - delete ((CPrivateData *)private_data); - private_data = NULL; - } + if (Background != NULL) + frameBuffer->RestoreScreen(x, y, dx, dy, Background); + delete[] Background; } void CFBWindow::paintBoxRel(const int _x, const int _y, const int _dx, const int _dy, const color_t _col, int radius, int type) { - ((CPrivateData *)private_data)->frameBuffer->paintBoxRel(x + _x, y + _y, _dx, _dy, _col, radius, type); + frameBuffer->paintBoxRel(x + _x, y + _y, _dx, _dy, _col, radius, type); } bool CFBWindow::paintIcon(const char * const _filename, const int _x, const int _y, const int _h, const color_t _offset) { - ((CPrivateData *)private_data)->frameBuffer->paintIcon(_filename, x + _x, y + _y, _h, _offset); + frameBuffer->paintIcon(_filename, x + _x, y + _y, _h, _offset); return 0; } diff --git a/src/driver/fb_window.h b/src/driver/fb_window.h index ec8fa857e..9e4a0b347 100644 --- a/src/driver/fb_window.h +++ b/src/driver/fb_window.h @@ -1,8 +1,4 @@ -#ifndef __fb_window_h__ -#define __fb_window_h__ /* - * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/fb_window.h,v 1.3 2004/03/13 12:45:41 thegoodguy Exp $ - * * abstract fb_window class - d-box2 linux project * * (C) 2003 by thegoodguy @@ -23,15 +19,21 @@ * */ +#ifndef __fb_window_h__ +#define __fb_window_h__ + +#include +#include + class CFBWindow { public: typedef unsigned int color_t; typedef void * font_t; - typedef void * private_data_t; private: - private_data_t private_data; + CFrameBuffer * frameBuffer; + fb_pixel_t * Background; public: int x, y; /* upper left corner */ From 58efee483561b22aed5b6b62226c1bc94d886113 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 3 May 2012 17:27:45 +0400 Subject: [PATCH 3/4] system/localize.cpp: fix destructor --- src/system/localize.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system/localize.cpp b/src/system/localize.cpp index dc924a4f6..bed4a433a 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -99,10 +99,16 @@ CLocaleManager::CLocaleManager() CLocaleManager::~CLocaleManager() { for (unsigned j = 0; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) - if (localeData[j] != locale_real_names[j]) + if (localeData[j] != locale_real_names[j] && localeData[j] != defaultData[j]) ::free(localeData[j]); - delete localeData; + delete[] localeData; + + for (unsigned j = 0; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) + if (defaultData[j] != locale_real_names[j]) + ::free(defaultData[j]); + + delete[] defaultData; } const char * path[2] = {"/var/tuxbox/config/locale/", DATADIR "/neutrino/locale/"}; From 99cc7ae30b2c85e5954d82ea5de2c20fc69bbb6b Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 3 May 2012 17:29:54 +0400 Subject: [PATCH 4/4] neutrino.h: comment unused OnekeyPluginChanger, MyIPChanger --- src/neutrino.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/neutrino.h b/src/neutrino.h index 32240c937..88c7d07c7 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -121,8 +121,8 @@ private: bool pbBlinkChange; CColorSetupNotifier *colorSetupNotifier; CMoviePluginChangeExec *MoviePluginChanger; - COnekeyPluginChangeExec *OnekeyPluginChanger; - CIPChangeNotifier *MyIPChanger; + //COnekeyPluginChangeExec *OnekeyPluginChanger; + //CIPChangeNotifier *MyIPChanger; void SDT_ReloadChannels(); void setupNetwork( bool force= false );