[MPlayer-dev-eng] [patch] Gui/interface.[c, h] const for string handling functions

Stefan Huehner stefan at huehner.org
Wed Jun 21 19:50:08 CEST 2006


Hi,

attached patch marks read-only parameters in the string handling
functions with const.

Regards,
Stefan

-------------- next part --------------
Index: interface.c
===================================================================
--- interface.c	(revision 18776)
+++ 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;
Index: interface.h
===================================================================
--- interface.h	(revision 18776)
+++ 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 ); }


More information about the MPlayer-dev-eng mailing list