[MPlayer-dev-eng] [patch] yet more const

Stefan Huehner stefan at huehner.org
Mon Jul 10 15:43:21 CEST 2006


Hi,                                                                             
                                                                                
attached paths marks several string parameters as const, when they are          
not modified in the function.                                                   
                                                                                
Regards,                                                                        
Stefan
-------------- next part --------------
--- Gui/interface.c	(revision 18994)
+++ Gui/interface.c	(working copy)
@@ -54,7 +54,7 @@
 guiInterface_t guiIntfStruct;
 int guiWinID=-1;
 
-char * gstrcat( char ** dest,char * src )
+char * gstrcat( char ** dest,const char * src )
 {
  char * tmp = NULL;
 
@@ -75,21 +75,21 @@
  return tmp;
 }
 
-int gstrcmp( char * a,char * b )
+int gstrcmp( const char * a,const char * b )
 {
  if ( !a && !b ) return 0;
  if ( !a || !b ) return -1;
  return strcmp( a,b );
 }
 
-int gstrncmp( char * a,char * b,int size )
+int gstrncmp( const char * a,const char * b,int size )
 {
  if ( !a && !b ) return 0;
  if ( !a || !b ) return -1;
  return strncmp( a,b,size );
 }
 
-char * gstrdup( char * str )
+char * gstrdup( const char * str )
 {
  if ( !str ) return NULL;
  return strdup( str );
@@ -107,7 +107,7 @@
  free( *p ); *p=NULL;
 }
 
-void gset( char ** str,char * what )
+void gset( char ** str, const char * what )
 {
  if ( *str ) { if ( !strstr( *str,what ) ) { gstrcat( str,"," ); gstrcat( str,what ); }}
    else gstrcat( str,what );
@@ -116,7 +116,7 @@
 /**
  * \brief this actually creates a new list containing only one element...
  */
-void gaddlist( char *** list,char * entry )
+void gaddlist( char *** list,const char * entry )
 {
  int i;
 
@@ -135,7 +135,7 @@
  * \brief this replaces a string starting with search by replace.
  * If not found, replace is appended.
  */
-void greplace(char ***list, char *search, char *replace)
+void greplace(char ***list, const char *search, const char *replace)
 {
  int i = 0;
  int len = (search) ? strlen(search) : 0;
--- Gui/interface.h	(revision 18994)
+++ Gui/interface.h	(working copy)
@@ -208,10 +208,10 @@
 extern void * gtkSet( int cmd,float param, void * vparam );
 
 extern char * gconvert_uri_to_filename( char * str );
-extern char * gstrdup( char * str );
-extern int    gstrcmp( char * a,char * b );
+extern char * gstrdup( const char * str );
+extern int    gstrcmp( const char * a,const char * b );
 extern void   gfree( void ** p );
-extern void   gaddlist( char *** list,char * entry );
+extern void   gaddlist( char *** list,const char * entry );
 extern char * gstrchr( char * str,int c );
 
 #define guiSetFilename( s,n ) { gfree( (void **)&s ); s=gstrdup( n ); }
--- Gui/mplayer/gtk/mb.c	(revision 18994)
+++ Gui/mplayer/gtk/mb.c	(working copy)
@@ -13,7 +13,7 @@
 GtkWidget * gtkMessageBoxText;
 GtkWidget * MessageBox = NULL;
 
-void ShowMessageBox( char * msg )
+void ShowMessageBox( const char * msg )
 {
  if ( MessageBox ) { gtk_widget_hide( MessageBox ); gtk_widget_destroy( MessageBox ); }
  MessageBox=create_MessageBox( 0 );
--- Gui/mplayer/gtk/mb.h	(revision 18994)
+++ Gui/mplayer/gtk/mb.h	(working copy)
@@ -8,6 +8,6 @@
 extern GtkWidget * MessageBox;
 
 extern GtkWidget * create_MessageBox( int type );
-extern void ShowMessageBox( char * msg );
+extern void ShowMessageBox( const char * msg );
 
 #endif
--- Gui/mplayer/gtk/menu.c	(revision 18994)
+++ Gui/mplayer/gtk/menu.c	(working copy)
@@ -70,7 +70,7 @@
  mplEventHandling( Item & 0x0000ffff,Item >> 16 );
 }
 
-GtkWidget * AddMenuCheckItem(GtkWidget *window1, const char * immagine_xpm, GtkWidget* Menu,char* label, gboolean state, int Number)
+static GtkWidget * AddMenuCheckItem(GtkWidget *window1, const char * immagine_xpm, GtkWidget* Menu,const char* label, gboolean state, int Number)
 {
  GtkWidget * Label = NULL;
  GtkWidget * Pixmap = NULL;
@@ -103,7 +103,7 @@
    
  return Item;
 }
-GtkWidget * AddMenuItem( GtkWidget *window1, const char * immagine_xpm,  GtkWidget * SubMenu,char * label,int Number )
+GtkWidget * AddMenuItem( GtkWidget *window1, const char * immagine_xpm,  GtkWidget * SubMenu,const char * label,int Number )
 {
  GtkWidget * Label = NULL;
  GtkWidget * Pixmap = NULL;
@@ -136,7 +136,7 @@
 }
 
 
-GtkWidget * AddSubMenu( GtkWidget *window1, const char * immagine_xpm, GtkWidget * Menu,char * label )
+GtkWidget * AddSubMenu( GtkWidget *window1, const char * immagine_xpm, GtkWidget * Menu,const char * label )
 {
  GtkWidget * Label = NULL;
  GtkWidget * Pixmap = NULL;
--- Gui/mplayer/gtk/menu.h	(revision 18994)
+++ Gui/mplayer/gtk/menu.h	(working copy)
@@ -5,8 +5,8 @@
 
 extern GtkWidget * DVDSubMenu;
 
-extern GtkWidget * AddMenuItem( GtkWidget *window1, const char * immagine_xpm,  GtkWidget * SubMenu,char * label,int Number );
-extern GtkWidget * AddSubMenu( GtkWidget *window1, const char * immagine_xpm, GtkWidget * Menu,char * label );
+extern GtkWidget * AddMenuItem( GtkWidget *window1, const char * immagine_xpm,  GtkWidget * SubMenu,const char * label,int Number );
+extern GtkWidget * AddSubMenu( GtkWidget *window1, const char * immagine_xpm, GtkWidget * Menu,const char * label );
 extern GtkWidget * AddSeparator( GtkWidget * Menu );
 extern GtkWidget * create_PopUpMenu( void );
 
--- Gui/mplayer/gtk/common.c	(revision 18994)
+++ Gui/mplayer/gtk/common.c	(working copy)
@@ -23,7 +23,7 @@
  return frame;
 }
 
-GtkWidget * AddFrame( char * title,int type,GtkWidget * parent,int add )
+GtkWidget * AddFrame( const char * title,int type,GtkWidget * parent,int add )
 {
  GtkWidget * frame = NULL;
  frame=gtk_frame_new( title );
@@ -36,7 +36,7 @@
  return frame;
 }
 
-GtkWidget * AddLabel( char * title,GtkWidget * parent )
+GtkWidget * AddLabel( const char * title,GtkWidget * parent )
 {
  GtkWidget * label;
  label=gtk_label_new( title );
@@ -76,7 +76,7 @@
  return hbox;
 }
 
-GtkWidget * AddCheckButton( char * title, GtkWidget * parent )
+GtkWidget * AddCheckButton( const char * title, GtkWidget * parent )
 {
  GtkWidget * CB;
  CB=gtk_check_button_new_with_label( title );
@@ -86,7 +86,7 @@
  return CB;
 }
 
-GtkWidget * AddRadioButton( char * title,GSList ** group,GtkWidget * parent )
+GtkWidget * AddRadioButton( const char * title,GSList ** group,GtkWidget * parent )
 {
  GtkWidget * RB;
  RB=gtk_radio_button_new_with_label( *group,title );
@@ -97,7 +97,7 @@
  return RB;
 }
 
-GtkWidget * AddButton( char * title,GtkWidget * parent )
+GtkWidget * AddButton( const char * title,GtkWidget * parent )
 {
  GtkWidget * B;
  B=gtk_button_new_with_label( title );
--- Gui/mplayer/gtk/common.h	(revision 18994)
+++ Gui/mplayer/gtk/common.h	(working copy)
@@ -6,13 +6,13 @@
 #include <gtk/gtk.h>
 
 extern GtkWidget * AddDialogFrame( GtkWidget * parent );
-extern GtkWidget * AddFrame( char * title,int type,GtkWidget * parent,int add );
-extern GtkWidget * AddLabel( char * title,GtkWidget * parent );
+extern GtkWidget * AddFrame( const char * title,int type,GtkWidget * parent,int add );
+extern GtkWidget * AddLabel( const char * title,GtkWidget * parent );
 extern GtkWidget * AddVBox( GtkWidget * parent,int type );
 extern GtkWidget * AddHBox( GtkWidget * parent,int type );
-extern GtkWidget * AddCheckButton( char * title, GtkWidget * parent );
-extern GtkWidget * AddRadioButton( char * title,GSList ** group,GtkWidget * parent );
-extern GtkWidget * AddButton( char * title,GtkWidget * parent );
+extern GtkWidget * AddCheckButton( const char * title, GtkWidget * parent );
+extern GtkWidget * AddRadioButton( const char * title,GSList ** group,GtkWidget * parent );
+extern GtkWidget * AddButton( const char * title,GtkWidget * parent );
 extern GtkWidget * AddHSeparator( GtkWidget * parent );
 extern GtkWidget * AddHButtonBox( GtkWidget * parent );
 extern GtkWidget * AddHScaler( GtkAdjustment * adj,GtkWidget * parent,int digit );
--- Gui/mplayer/widgets.c	(revision 18994)
+++ Gui/mplayer/widgets.c	(working copy)
@@ -112,7 +112,7 @@
 
 // --- funcs
 
-void gtkMessageBox( int type,gchar * str )
+void gtkMessageBox( int type,const gchar * str )
 {
  if ( !gtkInited ) return;
  ShowMessageBox( str );
--- Gui/mplayer/widgets.h	(revision 18994)
+++ Gui/mplayer/widgets.h	(working copy)
@@ -54,7 +54,7 @@
 extern void gtkEventHandling( void );
 
 extern void gtkShow( int type,char * param );
-extern void gtkMessageBox( int type,gchar * str );
+extern void gtkMessageBox( int type,const gchar * str );
 extern void gtkSetLayer( GtkWidget * wdg );
 extern void gtkActive( GtkWidget * wdg );
 
     int n = 0;


More information about the MPlayer-dev-eng mailing list