Mercurial > mplayer.hg
changeset 32927:edb972e22021
Fix memory leak in appInitStruct().
The NumberOf{Main,Bar,Menu}Items members actually don't hold the
number of items but the last index used. Therefore, the last item
won't get freed so far.
To set the correct "number" for the global external variable prior
to using it, the function appResetStruct() has been added and is used
in appInitStruct() as well.
author | ib |
---|---|
date | Thu, 03 Mar 2011 13:45:30 +0000 |
parents | 7c205a5c2a9b |
children | 0ef78cd3063b |
files | gui/app.c gui/app.h gui/interface.c |
diffstat | 3 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/app.c Thu Mar 03 13:13:20 2011 +0000 +++ b/gui/app.c Thu Mar 03 13:45:30 2011 +0000 @@ -106,24 +106,31 @@ item->tmp = 0; } +void appResetStruct(void) +{ + appMPlayer.NumberOfMainItems = -1; + appMPlayer.NumberOfBarItems = -1; + appMPlayer.NumberOfMenuItems = -1; + + appMPlayer.sub.x = -1; // NOTE TO MYSELF: is this really necessary? + appMPlayer.sub.y = -1; // NOTE TO MYSELF: is this really necessary? +} + void appInitStruct(void) { int i; - for (i = 0; i < appMPlayer.NumberOfMainItems; i++) + for (i = 0; i < appMPlayer.NumberOfMainItems + 1; i++) appClearItem(&appMPlayer.mainItems[i]); - for (i = 0; i < appMPlayer.NumberOfBarItems; i++) + for (i = 0; i < appMPlayer.NumberOfBarItems + 1; i++) appClearItem(&appMPlayer.barItems[i]); - for (i = 0; i < appMPlayer.NumberOfMenuItems; i++) + for (i = 0; i < appMPlayer.NumberOfMenuItems + 1; i++) appClearItem(&appMPlayer.menuItems[i]); - appMPlayer.NumberOfMainItems = -1; memset(appMPlayer.mainItems, 0, 256 * sizeof(wItem)); - appMPlayer.NumberOfMenuItems = -1; memset(appMPlayer.menuItems, 0, 64 * sizeof(wItem)); - appMPlayer.NumberOfBarItems = -1; memset(appMPlayer.barItems, 0, 256 * sizeof(wItem)); appClearItem(&appMPlayer.main); @@ -132,8 +139,6 @@ appClearItem(&appMPlayer.sub); appMPlayer.sub.width = 0; appMPlayer.sub.height = 0; - appMPlayer.sub.x = -1; - appMPlayer.sub.y = -1; appClearItem(&appMPlayer.menuBase); appClearItem(&appMPlayer.menuSelected); @@ -143,6 +148,8 @@ appMPlayer.main.R = appMPlayer.main.G = appMPlayer.main.B = 0; appMPlayer.barIsPresent = 0; appMPlayer.menuIsPresent = 0; + + appResetStruct(); } int appFindMessage(unsigned char *str)
--- a/gui/app.h Thu Mar 03 13:13:20 2011 +0000 +++ b/gui/app.h Thu Mar 03 13:45:30 2011 +0000 @@ -190,6 +190,7 @@ int appFindMessage(unsigned char *); void appInitStruct(void); +void appResetStruct(void); void btnModify(int, float); void btnSet(int, int);
--- a/gui/interface.c Thu Mar 03 13:13:20 2011 +0000 +++ b/gui/interface.c Thu Mar 03 13:45:30 2011 +0000 @@ -163,6 +163,8 @@ guiIntfStruct.Balance=50.0f; guiIntfStruct.StreamType=-1; + appResetStruct(); + memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); #ifdef CONFIG_DXR3 if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" );