[MPlayer-dev-eng] [patch] more const for function parameters & return values

Stefan Huehner stefan at huehner.org
Sat Jul 15 19:41:58 CEST 2006


Hi,

attached patch marks several read-only string parameters and function
return-values which can only be used read-only  as const.

Regards,
Stefan

-------------- next part --------------
--- libmpcodecs/img_format.c	(revision 19109)
+++ libmpcodecs/img_format.c	(working copy)
@@ -1,7 +1,7 @@
 #include "config.h"
 #include "img_format.h"
 
-char *vo_format_name(int format)
+const char *vo_format_name(int format)
 {
     switch(format)
     {
--- libmpcodecs/img_format.h	(revision 19109)
+++ libmpcodecs/img_format.h	(working copy)
@@ -114,6 +114,6 @@
     int timestamp; // pts, 90000 Hz counter based
 } vo_mpegpes_t;
 
-char *vo_format_name(int format);
+const char *vo_format_name(int format);
 
 #endif
--- libvo/video_out.h	(revision 19109)
+++ libvo/video_out.h	(working copy)
@@ -166,7 +166,7 @@
 
 } vo_functions_t;
 
-char *vo_format_name(int format);
+const char *vo_format_name(int format);
 int vo_init(void);
 
 vo_functions_t* init_best_video_out(char** vo_list);
--- libmpdemux/network.c	(revision 19109)
+++ libmpdemux/network.c	(working copy)
@@ -117,7 +117,7 @@
 
 // Converts an address family constant to a string
 
-char *af2String(int af) {
+const char *af2String(int af) {
 	switch (af) {
 		case AF_INET:	return "AF_INET";
 		
--- libmpdemux/asfheader.c	(revision 19109)
+++ libmpdemux/asfheader.c	(working copy)
@@ -77,7 +77,7 @@
   mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", name, string);
 }
 
-static char* asf_chunk_type(unsigned char* guid) {
+static const char* asf_chunk_type(unsigned char* guid) {
   static char tmp[60];
   char *p;
   int i;
--- libmpdemux/tvi_v4l2.c	(revision 19109)
+++ libmpdemux/tvi_v4l2.c	(working copy)
@@ -213,7 +213,7 @@
 ** Translate a video4linux2 fourcc aka pixel format
 ** to a human readable string.
 */
-static char *pixfmt2name(int pixfmt)
+static const char *pixfmt2name(int pixfmt)
 {
     static char unknown[24];
 
--- libmpdemux/librtsp/rtsp.c	(revision 19109)
+++ libmpdemux/librtsp/rtsp.c	(working copy)
@@ -705,7 +705,7 @@
 
 }
 
-char *rtsp_get_param(rtsp_t *s, char *p) {
+char *rtsp_get_param(rtsp_t *s, const char *p) {
   int len;
   char *param;
   if (!s->param)
--- libmpdemux/librtsp/rtsp.h	(revision 19109)
+++ libmpdemux/librtsp/rtsp.h	(working copy)
@@ -72,7 +72,7 @@
 char *rtsp_get_session(rtsp_t *s);
 
 char *rtsp_get_mrl(rtsp_t *s);
-char *rtsp_get_param(rtsp_t *s, char *param);
+char *rtsp_get_param(rtsp_t *s, const char *param);
 
 /*int      rtsp_peek_header (rtsp_t *this, char *data); */
 
--- libaf/af_format.h	(revision 19109)
+++ libaf/af_format.h	(working copy)
@@ -84,11 +84,11 @@
 #define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE
 #endif
 
-extern int af_str2fmt(char *str);
-extern int af_str2fmt_short(char *str);
+extern int af_str2fmt(const char *str);
+extern int af_str2fmt_short(const char *str);
 extern int af_fmt2bits(int format);
 extern int af_bits2fmt(int bits);
 extern char* af_fmt2str(int format, char* str, int size);
-extern char* af_fmt2str_short(int format);
+extern const char* af_fmt2str_short(int format);
 
 #endif /* __af_format_h__ */
--- libaf/format.c	(revision 19109)
+++ libaf/format.c	(working copy)
@@ -19,7 +19,7 @@
 #include "help_mp.h"
 
 // Convert from string to format
-int af_str2fmt(char* str)
+int af_str2fmt(const char* str)
 {
   int format=0;
   // Scan for endianess
@@ -178,18 +178,18 @@
     { NULL, 0 }
 };
 
-char *af_fmt2str_short(int format)
+const char *af_fmt2str_short(int format)
 {
     int i;
 
     for (i = 0; af_fmtstr_table[i].name; i++)
 	if (af_fmtstr_table[i].format == format)
-	    return (char*)(af_fmtstr_table[i].name);
+	    return af_fmtstr_table[i].name;
 
     return "??";
 }
 
-int af_str2fmt_short(char* str)
+int af_str2fmt_short(const char* str)
 {
     int i;
 


More information about the MPlayer-dev-eng mailing list