[MPlayer-cvslog] r33827 - in trunk/gui: interface.c interface.h skin/font.c ui/actions.c ui/gtk/equalizer.c ui/gtk/fileselect.c ui/gtk/playlist.c ui/gtk/preferences.c ui/main.c ui/playbar.c util/mem.h
ib
subversion at mplayerhq.hu
Thu Jul 7 11:29:15 CEST 2011
Author: ib
Date: Thu Jul 7 11:29:15 2011
New Revision: 33827
Log:
Remove gfree() from interface.c.
Rename it nfree() and define it as macro.
Added:
trunk/gui/util/mem.h
Modified:
trunk/gui/interface.c
trunk/gui/interface.h
trunk/gui/skin/font.c
trunk/gui/ui/actions.c
trunk/gui/ui/gtk/equalizer.c
trunk/gui/ui/gtk/fileselect.c
trunk/gui/ui/gtk/playlist.c
trunk/gui/ui/gtk/preferences.c
trunk/gui/ui/main.c
trunk/gui/ui/playbar.c
Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/interface.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -24,6 +24,7 @@
#include "skin/skin.h"
#include "ui/gmplayer.h"
#include "ui/widgets.h"
+#include "util/mem.h"
#include "util/string.h"
#include "wm/ws.h"
#include "wm/wsxdnd.h"
@@ -76,12 +77,6 @@ float gtkEquChannels[6][10];
static int initialized;
-void gfree(void **p)
-{
- free(*p);
- *p = NULL;
-}
-
/**
* \brief This actually creates a new list containing only one element...
*/
@@ -419,7 +414,7 @@ void guiLoadFont(void)
vo_font = read_font_desc(font_name, font_factor, 0);
if (!vo_font) {
- gfree((void **)&font_name);
+ nfree(font_name);
font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc");
vo_font = read_font_desc(font_name, font_factor, 0);
}
@@ -793,7 +788,7 @@ int gui(int what, void *arg)
if (guiInfo.AudioFile)
audio_stream = gstrdup(guiInfo.AudioFile);
else if (guiInfo.FilenameChanged)
- gfree((void **)&audio_stream);
+ nfree(audio_stream);
// audio_stream = NULL;
@@ -961,8 +956,8 @@ int gui(int what, void *arg)
guiSetDF(guiInfo.Filename, next->path, next->name);
guiInfo.StreamType = STREAMTYPE_FILE;
guiInfo.FilenameChanged = guiInfo.NewPlay = 1;
- gfree((void **)&guiInfo.AudioFile);
- gfree((void **)&guiInfo.Subtitlename);
+ nfree(guiInfo.AudioFile);
+ nfree(guiInfo.Subtitlename);
} else {
if (guiInfo.FilenameChanged || guiInfo.NewPlay)
break;
@@ -1221,7 +1216,7 @@ void *gtkSet(int cmd, float fparam, void
return NULL;
case gtkSetFontEncoding:
- gfree((void **)&subtitle_font_encoding);
+ nfree(subtitle_font_encoding);
subtitle_font_encoding = gstrdup((char *)vparam);
guiLoadFont();
return NULL;
@@ -1234,7 +1229,7 @@ void *gtkSet(int cmd, float fparam, void
#ifdef CONFIG_ICONV
case gtkSetSubEncoding:
- gfree((void **)&sub_cp);
+ nfree(sub_cp);
sub_cp = gstrdup((char *)vparam);
break;
#endif
@@ -1244,9 +1239,9 @@ void *gtkSet(int cmd, float fparam, void
case gtkClearStruct:
if ((unsigned int)vparam & guiFilenames) {
- gfree((void **)&guiInfo.Filename);
- gfree((void **)&guiInfo.Subtitlename);
- gfree((void **)&guiInfo.AudioFile);
+ nfree(guiInfo.Filename);
+ nfree(guiInfo.Subtitlename);
+ nfree(guiInfo.AudioFile);
gtkSet(gtkDelPl, 0, NULL);
}
Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/interface.h Thu Jul 7 11:29:15 2011 (r33827)
@@ -225,7 +225,6 @@ extern char *fsHistory[fsPersistant_MaxP
extern float gtkEquChannels[6][10];
void gaddlist(char ***list, const char *entry);
-void gfree(void **p);
void gmp_msg(int mod, int lev, const char *format, ...);
void *gtkSet(int cmd, float fparam, void *vparam);
void guiDone(void);
Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/skin/font.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -22,8 +22,8 @@
#include <string.h>
#include "font.h"
-#include "gui/interface.h"
#include "gui/util/cut.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "skin.h"
@@ -73,7 +73,7 @@ void fntFreeFont(void)
for (i = 0; i < MAX_FONTS; i++) {
if (Fonts[i]) {
bpFree(&Fonts[i]->Bitmap);
- gfree((void **)&Fonts[i]);
+ nfree(Fonts[i]);
}
}
}
@@ -97,7 +97,7 @@ int fntRead(char *path, char *fname)
f = fopen(buf, "rt");
if (!f) {
- gfree((void **)&Fonts[id]);
+ nfree(Fonts[id]);
return -3;
}
@@ -158,7 +158,7 @@ int fntRead(char *path, char *fname)
if (skinBPRead(buf, &Fonts[id]->Bitmap) != 0) {
bpFree(&Fonts[id]->Bitmap);
- gfree((void **)&Fonts[id]);
+ nfree(Fonts[id]);
fclose(f);
return -4;
}
Modified: trunk/gui/ui/actions.c
==============================================================================
--- trunk/gui/ui/actions.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/actions.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -25,6 +25,7 @@
#include "gui/interface.h"
#include "gui/skin/font.h"
#include "gui/skin/skin.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "gui/wm/wsxdnd.h"
#include "widgets.h"
@@ -261,8 +262,8 @@ void uiSetFileName(char *dir, char *name
guiSetDF(guiInfo.Filename, dir, name)
guiInfo.StreamType = type;
- gfree((void **)&guiInfo.AudioFile);
- gfree((void **)&guiInfo.Subtitlename);
+ nfree(guiInfo.AudioFile);
+ nfree(guiInfo.Subtitlename);
}
void uiCurr(void)
Modified: trunk/gui/ui/gtk/equalizer.c
==============================================================================
--- trunk/gui/ui/gtk/equalizer.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/gtk/equalizer.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -39,6 +39,7 @@
#include "libmpdemux/stheader.h"
#include "libmpcodecs/dec_video.h"
#include "gui/ui/widgets.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "equalizer.h"
@@ -562,12 +563,12 @@ static void ecButtonReleased( GtkButton
{
if ( (int)user_data )
{ // if you pressed Ok
- gfree( (void **)>kEquChannel1 ); gtkEquChannel1=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel1 ) ) );
- gfree( (void **)>kEquChannel2 ); gtkEquChannel2=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel2 ) ) );
- gfree( (void **)>kEquChannel3 ); gtkEquChannel3=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel3 ) ) );
- gfree( (void **)>kEquChannel4 ); gtkEquChannel4=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel4 ) ) );
- gfree( (void **)>kEquChannel5 ); gtkEquChannel5=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel5 ) ) );
- gfree( (void **)>kEquChannel6 ); gtkEquChannel6=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel6 ) ) );
+ nfree( gtkEquChannel1 ); gtkEquChannel1=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel1 ) ) );
+ nfree( gtkEquChannel2 ); gtkEquChannel2=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel2 ) ) );
+ nfree( gtkEquChannel3 ); gtkEquChannel3=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel3 ) ) );
+ nfree( gtkEquChannel4 ); gtkEquChannel4=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel4 ) ) );
+ nfree( gtkEquChannel5 ); gtkEquChannel5=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel5 ) ) );
+ nfree( gtkEquChannel6 ); gtkEquChannel6=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel6 ) ) );
eqSetChannelNames();
}
HideEquConfig();
Modified: trunk/gui/ui/gtk/fileselect.c
==============================================================================
--- trunk/gui/ui/gtk/fileselect.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/gtk/fileselect.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -32,6 +32,7 @@
#include "gui/app.h"
#include "gui/interface.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "help_mp.h"
#include "mpcommon.h"
@@ -371,7 +372,7 @@ static void fs_PersistantHistory( char *
char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp;
return;
}
- gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] );
+ nfree( fsHistory[fsPersistant_MaxPos - 1] );
for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1];
fsHistory[0]=gstrdup( subject );
}
@@ -480,8 +481,8 @@ static void fs_Ok_released( GtkButton *
guiSetDF( guiInfo.Filename,fsSelectedDirectory,fsSelectedFile );
guiInfo.StreamType=STREAMTYPE_FILE;
guiInfo.FilenameChanged=1; sub_fps=0;
- gfree( (void **)&guiInfo.AudioFile );
- gfree( (void **)&guiInfo.Subtitlename );
+ nfree( guiInfo.AudioFile );
+ nfree( guiInfo.Subtitlename );
fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history
break;
case fsSubtitleSelector:
Modified: trunk/gui/ui/gtk/playlist.c
==============================================================================
--- trunk/gui/ui/gtk/playlist.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/gtk/playlist.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -33,6 +33,7 @@
#include "gui/interface.h"
#include "gui/ui/widgets.h"
+#include "gui/util/mem.h"
#include "playlist.h"
#include "tools.h"
@@ -156,7 +157,7 @@ void HidePlayList( void )
{
if ( !PlayList ) return;
NrOfSelected=NrOfEntrys=0;
- gfree( (void **)&CLListSelected ); gfree( (void **)&CLFileSelected );
+ nfree( CLListSelected ); nfree( CLFileSelected );
free( old_path );
old_path=strdup( current_path );
gtk_widget_hide( PlayList );
Modified: trunk/gui/ui/gtk/preferences.c
==============================================================================
--- trunk/gui/ui/gtk/preferences.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/gtk/preferences.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -44,6 +44,7 @@
#include "gui/interface.h"
#include "gui/ui/gmplayer.h"
#include "gui/ui/widgets.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "preferences.h"
#include "fileselect.h"
@@ -1563,33 +1564,33 @@ static void audioButton(GtkButton *butto
case 1:
#ifdef CONFIG_OSS_AUDIO
if (strncmp(ao_driver[0], "oss", 3) == 0) {
- gfree((void **) >kAOOSSDevice);
+ nfree(gtkAOOSSDevice);
gtkAOOSSDevice = gstrdup(getGtkEntryText(CEAudioDevice));
- gfree((void **) >kAOOSSMixer);
+ nfree(gtkAOOSSMixer);
gtkAOOSSMixer = gstrdup(getGtkEntryText(CEAudioMixer));
- gfree((void **) >kAOOSSMixerChannel);
+ nfree(gtkAOOSSMixerChannel);
gtkAOOSSMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
}
#endif
#ifdef CONFIG_ALSA
if (strncmp(ao_driver[0], "alsa", 4) == 0) {
- gfree((void **) >kAOALSADevice);
+ nfree(gtkAOALSADevice);
gtkAOALSADevice = gstrdup(getGtkEntryText(CEAudioDevice));
- gfree((void **) >kAOALSAMixer);
+ nfree(gtkAOALSAMixer);
gtkAOALSAMixer = gstrdup(getGtkEntryText(CEAudioMixer));
- gfree((void **) >kAOALSAMixerChannel);
+ nfree(gtkAOALSAMixerChannel);
gtkAOALSAMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
}
#endif
#ifdef CONFIG_SDL
if (strncmp(ao_driver[0], "sdl", 3) == 0) {
- gfree((void **) >kAOSDLDriver);
+ nfree(gtkAOSDLDriver);
gtkAOSDLDriver = gstrdup(getGtkEntryText(CEAudioDevice));
}
#endif
#ifdef CONFIG_ESD
if (strncmp(ao_driver[0], "esd", 3) == 0) {
- gfree((void **) >kAOESDDevice);
+ nfree(gtkAOESDDevice);
gtkAOESDDevice = gstrdup(getGtkEntryText(CEAudioDevice));
}
#endif
@@ -1759,7 +1760,7 @@ static void dxr3Button( GtkButton * butt
switch ( (int)user_data )
{
case 0: // Ok
- gfree( (void **)>kDXR3Device ); gtkDXR3Device=strdup( gtk_entry_get_text( GTK_ENTRY( CEDXR3Device ) ) );
+ nfree( gtkDXR3Device ); gtkDXR3Device=strdup( gtk_entry_get_text( GTK_ENTRY( CEDXR3Device ) ) );
gtkVfLAVC=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBVLavc ) );
case 1: // Cancel
HideDXR3Config();
Modified: trunk/gui/ui/main.c
==============================================================================
--- trunk/gui/ui/main.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/main.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -30,6 +30,7 @@
#include "gui/interface.h"
#include "gui/skin/font.h"
#include "gui/skin/skin.h"
+#include "gui/util/mem.h"
#include "gui/util/string.h"
#include "gui/wm/ws.h"
@@ -111,8 +112,8 @@ void uiEventHandling( int msg,float para
break;
case evPlayNetwork:
- gfree( (void **)&guiInfo.Subtitlename );
- gfree( (void **)&guiInfo.AudioFile );
+ nfree( guiInfo.Subtitlename );
+ nfree( guiInfo.AudioFile );
guiInfo.StreamType=STREAMTYPE_STREAM;
goto play;
case evSetURL:
@@ -243,7 +244,7 @@ NoPause:
break;
case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break;
case evDropSubtitle:
- gfree( (void **)&guiInfo.Subtitlename );
+ nfree( guiInfo.Subtitlename );
guiLoadSubtitle( NULL );
break;
case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break;
@@ -594,7 +595,7 @@ void uiDandDHandler(int num,char** files
if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\
(type-supported)%4 == 0 && *(type+len) == '/'){
/* handle subtitle file */
- gfree((void**)&subtitles);
+ nfree(subtitles);
subtitles = str;
continue;
}
@@ -632,7 +633,7 @@ void uiDandDHandler(int num,char** files
uiEventHandling( evPlay,0 );
}
if (subtitles) {
- gfree((void**)&guiInfo.Subtitlename);
+ nfree(guiInfo.Subtitlename);
guiInfo.Subtitlename = subtitles;
guiLoadSubtitle(guiInfo.Subtitlename);
}
Modified: trunk/gui/ui/playbar.c
==============================================================================
--- trunk/gui/ui/playbar.c Thu Jul 7 10:48:46 2011 (r33826)
+++ trunk/gui/ui/playbar.c Thu Jul 7 11:29:15 2011 (r33827)
@@ -29,6 +29,7 @@
#include "gui/interface.h"
#include "gui/skin/font.h"
#include "gui/skin/skin.h"
+#include "gui/util/mem.h"
#include "gui/wm/ws.h"
#include "help_mp.h"
@@ -243,7 +244,7 @@ void uiPlaybarInit( void )
{
if ( !guiApp.playbarIsPresent ) return;
- gfree( (void**)&playbarDrawBuffer );
+ nfree( playbarDrawBuffer );
if ( ( playbarDrawBuffer = malloc( guiApp.playbar.Bitmap.ImageSize ) ) == NULL )
{
Added: trunk/gui/util/mem.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/gui/util/mem.h Thu Jul 7 11:29:15 2011 (r33827)
@@ -0,0 +1,26 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_GUI_MEM_H
+#define MPLAYER_GUI_MEM_H
+
+#include <stdlib.h>
+
+#define nfree(p) do { free(p); p = NULL; } while (0)
+
+#endif /* MPLAYER_GUI_MEM_H */
More information about the MPlayer-cvslog
mailing list