mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 01:22:30 +00:00
rm unnecesary void* casts - part 1
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18874 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a01ba6cb74
commit
5b4ec50d44
12
asxparser.c
12
asxparser.c
@ -118,7 +118,7 @@ asx_warning_attrib_invalid(ASX_Parser_t* parser, char* elem, char* attrib,
|
||||
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 @@ asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs) {
|
||||
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 @@ asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs) {
|
||||
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 @@ asx_get_element(ASX_Parser_t* parser,char** _buffer,
|
||||
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 @@ asx_get_element(ASX_Parser_t* parser,char** _buffer,
|
||||
|
||||
// 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 @@ asx_get_element(ASX_Parser_t* parser,char** _buffer,
|
||||
// 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';
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){
|
||||
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);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ int VbrControl_init_2pass_vbr_encoding(const char *filename, int bitrate, double
|
||||
// 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;
|
||||
|
@ -574,7 +574,7 @@ static int parse_str_list(m_option_t* opt,char *name, char *param, void* dst, in
|
||||
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 @@ static void copy_str_list(m_option_t* opt,void* dst, void* src) {
|
||||
|
||||
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;
|
||||
|
||||
|
@ -830,7 +830,7 @@ play_tree_iter_new_copy(play_tree_iter_t* old) {
|
||||
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 @@ play_tree_iter_new_copy(play_tree_iter_t* old) {
|
||||
;
|
||||
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);
|
||||
|
@ -53,7 +53,7 @@ play_tree_parser_get_line(play_tree_parser_t* p) {
|
||||
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;
|
||||
}
|
||||
|
53
subreader.c
53
subreader.c
@ -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 @@ int sub_format=SUB_INVALID;
|
||||
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 @@ char *sub_readtext(char *source, char **dest) {
|
||||
p++,len++;
|
||||
}
|
||||
|
||||
*dest= (char *)malloc (len+1);
|
||||
*dest= malloc (len+1);
|
||||
if (!dest) {return ERR;}
|
||||
|
||||
strncpy(*dest, source, len);
|
||||
@ -329,7 +326,7 @@ subtitle *sub_read_line_subrip(stream_t* st, subtitle *current) {
|
||||
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 @@ subtitle *sub_read_line_subviewer(stream_t *st,subtitle *current) {
|
||||
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 @@ subtitle *sub_read_line_subviewer2(stream_t *st,subtitle *current) {
|
||||
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 @@ subtitle *sub_read_line_ssa(stream_t *st,subtitle *current) {
|
||||
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 @@ subtitle* subcp_recode (subtitle *sub)
|
||||
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 @@ subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
|
||||
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 @@ void* guess_cp(stream_t *st, char *preferred_language, char *fallback)
|
||||
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 @@ sub_data* sub_read_file (char *filename, float fps) {
|
||||
#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 @@ sub_data* sub_read_file (char *filename, float fps) {
|
||||
}
|
||||
|
||||
#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 @@ if ((suboverlap_enabled == 2) ||
|
||||
// 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 @@ if ((suboverlap_enabled == 2) ||
|
||||
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 @@ char** sub_filenames(char* path, char *fname)
|
||||
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);
|
||||
f_dir = malloc(len);
|
||||
f_fname = malloc(len);
|
||||
f_fname_noext = malloc(len);
|
||||
f_fname_trim = malloc(len);
|
||||
|
||||
tmp_fname_noext = (char*)malloc(len);
|
||||
tmp_fname_trim = (char*)malloc(len);
|
||||
tmp_fname_ext = (char*)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 @@ char** sub_filenames(char* path, char *fname)
|
||||
|
||||
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 @@ char** sub_filenames(char* path, char *fname)
|
||||
|
||||
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++) {
|
||||
|
@ -704,7 +704,7 @@ static int vbr_init_2pass2(void *sstate)
|
||||
|
||||
/* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user