[MPlayer-cvslog] r18874 - in trunk: asxparser.c cpudetect.c divx4_vbr.c m_option.c playtree.c playtreeparser.c subreader.c xvid_vbr.c

reynaldo subversion at mplayerhq.hu
Sat Jul 1 05:56:18 CEST 2006


Author: reynaldo
Date: Sat Jul  1 05:56:13 2006
New Revision: 18874

Modified:
   trunk/asxparser.c
   trunk/cpudetect.c
   trunk/divx4_vbr.c
   trunk/m_option.c
   trunk/playtree.c
   trunk/playtreeparser.c
   trunk/subreader.c
   trunk/xvid_vbr.c

Log:
rm unnecesary void* casts - part 1

Modified: trunk/asxparser.c
==============================================================================
--- trunk/asxparser.c	(original)
+++ trunk/asxparser.c	Sat Jul  1 05:56:13 2006
@@ -118,7 +118,7 @@
     len += strlen(ptr[0]);
     len += ((ptr[1] == NULL) ? 4 : 2);
   }
-  str = vals = (char*)malloc(len);
+  str = vals = malloc(len);
   vals += sprintf(vals,"%s",valid_vals[0]);
   for(ptr = valid_vals + 1 ; ptr[0] != NULL ; ptr++) {
     if(ptr[1] == NULL)
@@ -189,7 +189,7 @@
 	break;
       }
     }
-    attrib = (char*)malloc(ptr2-ptr1+2);
+    attrib = malloc(ptr2-ptr1+2);
     strncpy(attrib,ptr1,ptr2-ptr1+1);
     attrib[ptr2-ptr1+1] = '\0';
 
@@ -207,7 +207,7 @@
       break;
     }
     ptr1++;
-    val = (char*)malloc(ptr2-ptr1+1);
+    val = malloc(ptr2-ptr1+1);
     strncpy(val,ptr1,ptr2-ptr1);
     val[ptr2-ptr1] = '\0';
     n_attrib++;
@@ -322,7 +322,7 @@
     if(ptr2[0] == '\n') parser->line++;
   }
 
-  element = (char*)malloc(ptr2-ptr1+1);
+  element = malloc(ptr2-ptr1+1);
   strncpy(element,ptr1,ptr2-ptr1);
   element[ptr2-ptr1] = '\0';
 
@@ -352,7 +352,7 @@
 
   // Save attribs string
   if(ptr3-ptr2 > 0) {
-    attribs = (char*)malloc(ptr3-ptr2+1);
+    attribs = malloc(ptr3-ptr2+1);
     strncpy(attribs,ptr2,ptr3-ptr2);
     attribs[ptr3-ptr2] = '\0';
   }
@@ -411,7 +411,7 @@
 	  //	    if(ptr4[0] == '\0') parser->line--;
 	  //}
 	  ptr4++;
-	  body = (char*)malloc(ptr4-ptr3+1);
+	  body = malloc(ptr4-ptr3+1);
 	  strncpy(body,ptr3,ptr4-ptr3);
 	  body[ptr4-ptr3] = '\0';	  
 	}

Modified: trunk/cpudetect.c
==============================================================================
--- trunk/cpudetect.c	(original)
+++ trunk/cpudetect.c	Sat Jul  1 05:56:13 2006
@@ -235,7 +235,7 @@
 	char *retname;
 	int i;
 
-	if (NULL==(retname=(char*)malloc(256))) {
+	if (NULL==(retname=malloc(256))) {
 		mp_msg(MSGT_CPUDETECT,MSGL_FATAL,"Error: GetCpuFriendlyName() not enough memory\n");
 		exit(1);
 	}

Modified: trunk/divx4_vbr.c
==============================================================================
--- trunk/divx4_vbr.c	(original)
+++ trunk/divx4_vbr.c	Sat Jul  1 05:56:13 2006
@@ -202,7 +202,7 @@
 //		    fprintf(stderr, "(%s) frames %d, texture %lld, motion %lld, total %lld, complexity %lld\n", __FILE__, iNumFrames, text_bits, motion_bits, total_bits, complexity);
 //		}
 		
-		m_vFrames = (entry*)malloc(iNumFrames*sizeof(entry));
+		m_vFrames = malloc(iNumFrames*sizeof(entry));
 		if (!m_vFrames) 
 		{	mp_msg(MSGT_FIXME, MSGL_FIXME,MSGTR_OutOfMemory);
 			return -2; //TC_EXPORT_ERROR;

Modified: trunk/m_option.c
==============================================================================
--- trunk/m_option.c	(original)
+++ trunk/m_option.c	Sat Jul  1 05:56:13 2006
@@ -574,7 +574,7 @@
       break;
     }
     len = ptr - last_ptr;
-    res[n] = (char*)malloc(len + 1);
+    res[n] = malloc(len + 1);
     if(len) strncpy(res[n],last_ptr,len);
     res[n][len] = '\0';
     ptr++;
@@ -615,7 +615,7 @@
 
   for(n = 0 ; s[n] != NULL ; n++)
     /* NOTHING */;
-  d = (char**)malloc((n+1)*sizeof(char*));
+  d = malloc((n+1)*sizeof(char*));
   for( ; n >= 0 ; n--)
     d[n] = s[n] ? strdup(s[n]) : NULL;
 

Modified: trunk/playtree.c
==============================================================================
--- trunk/playtree.c	(original)
+++ trunk/playtree.c	Sat Jul  1 05:56:13 2006
@@ -830,7 +830,7 @@
   assert(old != NULL);
 #endif
 
-  iter = (play_tree_iter_t*)malloc(sizeof(play_tree_iter_t));
+  iter = malloc(sizeof(play_tree_iter_t));
   if(iter == NULL) {
     mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",sizeof(play_tree_iter_t));
     return NULL;
@@ -838,7 +838,7 @@
 ;
   memcpy(iter,old,sizeof(play_tree_iter_t));
   if(old->status_stack) {
-    iter->status_stack = (int*)malloc(old->stack_size * sizeof(int));
+    iter->status_stack = malloc(old->stack_size * sizeof(int));
     if(iter->status_stack == NULL) {
       mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",old->stack_size * sizeof(int));
       free(iter);

Modified: trunk/playtreeparser.c
==============================================================================
--- trunk/playtreeparser.c	(original)
+++ trunk/playtreeparser.c	Sat Jul  1 05:56:13 2006
@@ -53,7 +53,7 @@
   int r,resize = 0;
 
   if(p->buffer == NULL) {
-    p->buffer = (char*)malloc(BUF_STEP);
+    p->buffer = malloc(BUF_STEP);
     p->buffer_size = BUF_STEP;
     p->iter = p->buffer;
   }

Modified: trunk/subreader.c
==============================================================================
--- trunk/subreader.c	(original)
+++ trunk/subreader.c	Sat Jul  1 05:56:13 2006
@@ -25,6 +25,7 @@
 #endif
 
 #define ERR ((void *) -1)
+#define eol(x) ((x)=='\r' || (x)=='\n' || (x)=='\0')
 
 #ifdef USE_ICONV
 #include <iconv.h>
@@ -67,10 +68,6 @@
 unsigned long previous_sub_end;
 #endif
 
-static int eol(char p) {
-    return (p=='\r' || p=='\n' || p=='\0');
-}
-
 /* Remove leading and trailing space */
 static void trail_space(char *s) {
 	int i = 0;
@@ -246,7 +243,7 @@
 	p++,len++;
     }
     
-    *dest= (char *)malloc (len+1);
+    *dest= malloc (len+1);
     if (!dest) {return ERR;}
     
     strncpy(*dest, source, len);
@@ -329,7 +326,7 @@
 	p=q=line;
 	for (current->lines=1; current->lines < SUB_MAX_TEXT; current->lines++) {
 	    for (q=p,len=0; *p && *p!='\r' && *p!='\n' && *p!='|' && strncmp(p,"[br]",4); p++,len++);
-	    current->text[current->lines-1]=(char *)malloc (len+1);
+	    current->text[current->lines-1]=malloc (len+1);
 	    if (!current->text[current->lines-1]) return ERR;
 	    strncpy (current->text[current->lines-1], q, len);
 	    current->text[current->lines-1][len]='\0';
@@ -360,7 +357,7 @@
 	    for (p=line; *p!='\n' && *p!='\r' && *p; p++,len++);
 	    if (len) {
                 int j=0,skip=0;
-		char *curptr=current->text[i]=(char *)malloc (len+1);
+		char *curptr=current->text[i]=malloc (len+1);
 		if (!current->text[i]) return ERR;
 		//strncpy (current->text[i], line, len); current->text[i][len]='\0';
                 for(; j<len; j++) {
@@ -410,7 +407,7 @@
             len=0;
             for (p=line; *p!='\n' && *p!='\r' && *p; ++p,++len);
             if (len) {
-                current->text[i]=(char *)malloc (len+1);
+                current->text[i]=malloc (len+1);
                 if (!current->text[i]) return ERR;
                 strncpy (current->text[i], line, len); current->text[i][len]='\0';
                 ++i;
@@ -577,7 +574,7 @@
 	current->end   = 360000*hour2 + 6000*min2 + 100*sec2 + hunsec2;
 	
         while (((tmp=strstr(line2, "\\n")) != NULL) || ((tmp=strstr(line2, "\\N")) != NULL) ){
-		current->text[num]=(char *)malloc(tmp-line2+1);
+		current->text[num]=malloc(tmp-line2+1);
 		strncpy (current->text[num], line2, tmp-line2);
 		current->text[num][tmp-line2]='\0';
 		line2=tmp+2;
@@ -1136,7 +1133,7 @@
 			l++;
 			break;
 		}
-		if (!(ot = (char *)malloc(op - icbuffer + 1))){
+		if (!(ot = malloc(op - icbuffer + 1))){
 			mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
 			l++;
 		   	break;
@@ -1218,7 +1215,7 @@
     if(log2vis) {
       len = fribidi_remove_bidi_marks (visual, len, NULL, NULL,
 				       NULL);
-      if((op = (char*)malloc((max(2*orig_len,2*len) + 1))) == NULL) {
+      if((op = malloc((max(2*orig_len,2*len) + 1))) == NULL) {
 	mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
 	l++;
 	break;	
@@ -1314,7 +1311,7 @@
     char *detected_sub_cp = NULL;
     int i;
 
-    buffer = (unsigned char*)malloc(MAX_GUESS_BUFFER_SIZE);
+    buffer = malloc(MAX_GUESS_BUFFER_SIZE);
     buflen = stream_read(st,buffer, MAX_GUESS_BUFFER_SIZE);
 
     languages = enca_get_languages(&langcnt);
@@ -1408,7 +1405,7 @@
 #endif
 
     sub_num=0;n_max=32;
-    first=(subtitle *)malloc(n_max*sizeof(subtitle));
+    first=malloc(n_max*sizeof(subtitle));
     if(!first){
 #ifdef USE_ICONV
 	  subcp_close();
@@ -1418,7 +1415,7 @@
     }
     
 #ifdef USE_SORTSUB
-    sub = (subtitle *)malloc(sizeof(subtitle));
+    sub = malloc(sizeof(subtitle));
     //This is to deal with those formats (AQT & Subrip) which define the end of a subtitle
     //as the beginning of the following
     previous_sub_end = 0;
@@ -1548,9 +1545,9 @@
 	// used by the subs, a 'placeholder'
 	counter = 2 * sub_to_add + 1;  // the maximum number of subs derived
 	                               // from a block of sub_to_add+1 subs
-	placeholder = (int **) malloc(sizeof(int *) * counter);
+	placeholder = malloc(sizeof(int *) * counter);
 	for (i = 0; i < counter; ++i) {
-	    placeholder[i] = (int *) malloc(sizeof(int) * lines_to_add);
+	    placeholder[i] = malloc(sizeof(int) * lines_to_add);
 	    for (j = 0; j < lines_to_add; ++j) {
 		placeholder[i][j] = -1;
 	    }
@@ -1721,7 +1718,7 @@
     return_sub = first;
 }
     if (return_sub == NULL) return NULL;
-    subt_data = (sub_data *)malloc(sizeof(sub_data));
+    subt_data = malloc(sizeof(sub_data));
     subt_data->filename = strdup(filename);
     subt_data->sub_uses_time = uses_time;
     subt_data->sub_num = sub_num;
@@ -1840,18 +1837,18 @@
     len = (strlen(fname) > 256 ? strlen(fname) : 256)
 	+(strlen(path) > 256 ? strlen(path) : 256)+2;
 
-    f_dir = (char*)malloc(len);
-    f_fname = (char*)malloc(len);
-    f_fname_noext = (char*)malloc(len);
-    f_fname_trim = (char*)malloc(len);
-
-    tmp_fname_noext = (char*)malloc(len);
-    tmp_fname_trim = (char*)malloc(len);
-    tmp_fname_ext = (char*)malloc(len);
+    f_dir = malloc(len);
+    f_fname = malloc(len);
+    f_fname_noext = malloc(len);
+    f_fname_trim = malloc(len);
+
+    tmp_fname_noext = malloc(len);
+    tmp_fname_trim = malloc(len);
+    tmp_fname_ext = malloc(len);
 
-    tmpresult = (char*)malloc(len);
+    tmpresult = malloc(len);
 
-    result = (subfn*)malloc(sizeof(subfn)*MAX_SUBTITLE_FILES);
+    result = malloc(sizeof(subfn)*MAX_SUBTITLE_FILES);
     memset(result, 0, sizeof(subfn)*MAX_SUBTITLE_FILES);
     
     subcnt = 0;
@@ -1877,7 +1874,7 @@
 
     tmp_sub_id = NULL;
     if (dvdsub_lang && !whiteonly(dvdsub_lang)) {
-	tmp_sub_id = (char*)malloc(strlen(dvdsub_lang)+1);
+	tmp_sub_id = malloc(strlen(dvdsub_lang)+1);
 	strcpy_trim(tmp_sub_id, dvdsub_lang);
     }
 
@@ -1989,7 +1986,7 @@
 
     qsort(result, subcnt, sizeof(subfn), compare_sub_priority);
 
-    result2 = (char**)malloc(sizeof(char*)*(subcnt+1));
+    result2 = malloc(sizeof(char*)*(subcnt+1));
     memset(result2, 0, sizeof(char*)*(subcnt+1));
 
     for (i = 0; i < subcnt; i++) {

Modified: trunk/xvid_vbr.c
==============================================================================
--- trunk/xvid_vbr.c	(original)
+++ trunk/xvid_vbr.c	Sat Jul  1 05:56:13 2006
@@ -704,7 +704,7 @@
 
 	/* Allocate memory space for the keyframe_location array */
 	if((state->keyframe_locations
-	    = (int*)malloc((state->nb_keyframes+1)*sizeof(int))) == NULL) {
+	    = malloc((state->nb_keyframes+1)*sizeof(int))) == NULL) {
 		fclose(state->pass1_file);
 		state->pass1_file = NULL;
 		return(-1);



More information about the MPlayer-cvslog mailing list