Commit a7317a9a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

By definition of sizeof, sizeof(char) = 1

parent eb9963eb
...@@ -2429,7 +2429,7 @@ char *dvbsi_to_utf8( char *psz_instring, size_t i_length ) ...@@ -2429,7 +2429,7 @@ char *dvbsi_to_utf8( char *psz_instring, size_t i_length )
iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding ); iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding );
i_in = i_length - (psz_stringstart - psz_instring ); i_in = i_length - (psz_stringstart - psz_instring );
i_out = i_in * 6; i_out = i_in * 6;
psz_outstring = psz_tmp = (char*)malloc( i_out * sizeof(char) + 1 ); psz_outstring = psz_tmp = (char*)malloc( i_out + 1 );
vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out ); vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out );
vlc_iconv_close( iconv_handle ); vlc_iconv_close( iconv_handle );
*psz_tmp = '\0'; *psz_tmp = '\0';
......
...@@ -439,7 +439,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt ...@@ -439,7 +439,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
desc=sdpplin_parse(data); desc=sdpplin_parse(data);
if( !desc ) return NULL; if( !desc ) return NULL;
buf= (char *)malloc(sizeof(char)*2048); buf= (char *)malloc(2048);
if( !buf ) goto error; if( !buf ) goto error;
header = (rmff_header_t*)malloc(sizeof(rmff_header_t)); header = (rmff_header_t*)malloc(sizeof(rmff_header_t));
...@@ -615,7 +615,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw ...@@ -615,7 +615,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
char challenge2[64]; char challenge2[64];
char checksum[34]; char checksum[34];
char *subscribe=NULL; char *subscribe=NULL;
char *buf=(char*)malloc(sizeof(char)*256); char *buf=(char*)malloc(256);
char *mrl=rtsp_get_mrl(rtsp_session); char *mrl=rtsp_get_mrl(rtsp_session);
unsigned int size; unsigned int size;
int status; int status;
...@@ -668,7 +668,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw ...@@ -668,7 +668,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
lprintf("Stream description size: %i\n", size); lprintf("Stream description size: %i\n", size);
description = (char*)malloc(sizeof(char)*(size+1)); description = (char*)malloc(size+1);
if( !description ) if( !description )
goto error; goto error;
if( rtsp_read_data(rtsp_session, (uint8_t*)description, size) <= 0) if( rtsp_read_data(rtsp_session, (uint8_t*)description, size) <= 0)
...@@ -677,7 +677,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw ...@@ -677,7 +677,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
//fprintf(stderr, "%s", description); //fprintf(stderr, "%s", description);
/* parse sdp (sdpplin) and create a header and a subscribe string */ /* parse sdp (sdpplin) and create a header and a subscribe string */
subscribe = (char *) malloc(sizeof(char)*256); subscribe = (char *) malloc(256);
if( !subscribe ) if( !subscribe )
goto error; goto error;
......
...@@ -381,7 +381,7 @@ rmff_mdpr_t *rmff_new_mdpr( ...@@ -381,7 +381,7 @@ rmff_mdpr_t *rmff_new_mdpr(
} }
mdpr->type_specific_len=type_specific_len; mdpr->type_specific_len=type_specific_len;
mdpr->type_specific_data = malloc(sizeof(char)*type_specific_len); mdpr->type_specific_data = malloc(type_specific_len);
if( !mdpr->type_specific_data ) { if( !mdpr->type_specific_data ) {
free( mdpr->stream_name ); free( mdpr->stream_name );
free( mdpr ); free( mdpr );
......
...@@ -193,7 +193,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { ...@@ -193,7 +193,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
if(filter(*data,"a=OpaqueData:buffer;",&buf, BUFLEN)) { if(filter(*data,"a=OpaqueData:buffer;",&buf, BUFLEN)) {
decoded = b64_decode(buf, decoded, &(desc->mlti_data_size)); decoded = b64_decode(buf, decoded, &(desc->mlti_data_size));
if ( decoded != NULL ) { if ( decoded != NULL ) {
desc->mlti_data = malloc(sizeof(char)*desc->mlti_data_size); desc->mlti_data = malloc(desc->mlti_data_size);
memcpy(desc->mlti_data, decoded, desc->mlti_data_size); memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
handled=1; handled=1;
*data=nl(*data); *data=nl(*data);
......
...@@ -201,7 +201,7 @@ xtag_slurp_to (XTagParser * parser, int good_end, int bad_end) ...@@ -201,7 +201,7 @@ xtag_slurp_to (XTagParser * parser, int good_end, int bad_end)
xi = xtag_index (parser, good_end | bad_end); xi = xtag_index (parser, good_end | bad_end);
if (xi > 0 && xtag_cin (s[xi], good_end)) { if (xi > 0 && xtag_cin (s[xi], good_end)) {
ret = malloc ((xi+1) * sizeof(char)); ret = malloc (xi+1);
strncpy (ret, s, xi); strncpy (ret, s, xi);
ret[xi] = '\0'; ret[xi] = '\0';
parser->start = &s[xi]; parser->start = &s[xi];
...@@ -255,7 +255,7 @@ xtag_slurp_quoted (XTagParser * parser) ...@@ -255,7 +255,7 @@ xtag_slurp_quoted (XTagParser * parser)
} }
} }
ret = malloc ((xi+1) * sizeof(char)); ret = malloc (xi+1);
strncpy (ret, s, xi); strncpy (ret, s, xi);
ret[xi] = '\0'; ret[xi] = '\0';
parser->start = &s[xi]; parser->start = &s[xi];
......
...@@ -382,8 +382,7 @@ char *XURL_GetHead( const char *psz_path ) ...@@ -382,8 +382,7 @@ char *XURL_GetHead( const char *psz_path )
size_t i_characters_until_last_slash; size_t i_characters_until_last_slash;
i_characters_until_last_slash = pc_last_slash - psz_path; i_characters_until_last_slash = pc_last_slash - psz_path;
psz_path_head = malloc( psz_path_head = malloc( i_characters_until_last_slash + 1 );
( i_characters_until_last_slash + 1 ) * sizeof(char) );
strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 ); strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 );
/* terminate the resulting string with '\0' */ /* terminate the resulting string with '\0' */
......
...@@ -172,7 +172,7 @@ static void MkvTree( demux_t & demuxer, int i_level, const char *psz_format, ... ...@@ -172,7 +172,7 @@ static void MkvTree( demux_t & demuxer, int i_level, const char *psz_format, ...
} }
va_start( args, psz_format ); va_start( args, psz_format );
static const char psz_foo[] = "| | | | | | | | | |"; static const char psz_foo[] = "| | | | | | | | | |";
char *psz_foo2 = (char*)malloc( ( i_level * 4 + 3 + strlen( psz_format ) ) * sizeof(char) ); char *psz_foo2 = (char*)malloc( i_level * 4 + 3 + strlen( psz_format ) );
strncpy( psz_foo2, psz_foo, 4 * i_level ); strncpy( psz_foo2, psz_foo, 4 * i_level );
psz_foo2[ 4 * i_level ] = '+'; psz_foo2[ 4 * i_level ] = '+';
psz_foo2[ 4 * i_level + 1 ] = ' '; psz_foo2[ 4 * i_level + 1 ] = ' ';
......
...@@ -240,7 +240,7 @@ static int Demux( demux_t *p_demux ) ...@@ -240,7 +240,7 @@ static int Demux( demux_t *p_demux )
int64_t i_pos = 0; int64_t i_pos = 0;
p_sys->i_data_len = stream_Size( p_demux->s ) +1; /* This is a cheat to prevent unnecessary realloc */ p_sys->i_data_len = stream_Size( p_demux->s ) +1; /* This is a cheat to prevent unnecessary realloc */
if( p_sys->i_data_len <= 0 && p_sys->i_data_len < 16384 ) p_sys->i_data_len = 1024; if( p_sys->i_data_len <= 0 && p_sys->i_data_len < 16384 ) p_sys->i_data_len = 1024;
p_sys->psz_data = malloc( p_sys->i_data_len * sizeof(char) +1); p_sys->psz_data = malloc( p_sys->i_data_len +1);
/* load the complete file */ /* load the complete file */
for( ;; ) for( ;; )
...@@ -310,7 +310,7 @@ static int Demux( demux_t *p_demux ) ...@@ -310,7 +310,7 @@ static int Demux( demux_t *p_demux )
i_strlen = psz_parse-psz_backup; i_strlen = psz_parse-psz_backup;
if( i_strlen < 1 ) continue; if( i_strlen < 1 ) continue;
msg_Dbg( p_demux, "param name strlen: %d", i_strlen); msg_Dbg( p_demux, "param name strlen: %d", i_strlen);
psz_string = malloc( i_strlen *sizeof( char ) +1); psz_string = malloc( i_strlen + 1);
memcpy( psz_string, psz_backup, i_strlen ); memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0'; psz_string[i_strlen] = '\0';
msg_Dbg( p_demux, "param name: %s", psz_string); msg_Dbg( p_demux, "param name: %s", psz_string);
...@@ -332,7 +332,7 @@ static int Demux( demux_t *p_demux ) ...@@ -332,7 +332,7 @@ static int Demux( demux_t *p_demux )
i_strlen = psz_parse-psz_backup; i_strlen = psz_parse-psz_backup;
if( i_strlen < 1 ) continue; if( i_strlen < 1 ) continue;
msg_Dbg( p_demux, "param value strlen: %d", i_strlen); msg_Dbg( p_demux, "param value strlen: %d", i_strlen);
psz_string = malloc( i_strlen *sizeof( char ) +1); psz_string = malloc( i_strlen +1);
memcpy( psz_string, psz_backup, i_strlen ); memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0'; psz_string[i_strlen] = '\0';
msg_Dbg( p_demux, "param value: %s", psz_string); msg_Dbg( p_demux, "param value: %s", psz_string);
...@@ -455,7 +455,7 @@ static int Demux( demux_t *p_demux ) ...@@ -455,7 +455,7 @@ static int Demux( demux_t *p_demux )
{ {
i_strlen = psz_parse-psz_backup; i_strlen = psz_parse-psz_backup;
if( i_strlen < 1 ) continue; if( i_strlen < 1 ) continue;
psz_string = malloc( i_strlen*sizeof( char ) +1); psz_string = malloc( i_strlen +1);
memcpy( psz_string, psz_backup, i_strlen ); memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0'; psz_string[i_strlen] = '\0';
input_item_t *p_input; input_item_t *p_input;
...@@ -603,7 +603,7 @@ static int Demux( demux_t *p_demux ) ...@@ -603,7 +603,7 @@ static int Demux( demux_t *p_demux )
if( i_strlen < 1 ) continue; if( i_strlen < 1 ) continue;
FREENULL(psz_href); FREENULL(psz_href);
psz_href = malloc( i_strlen*sizeof( char ) +1); psz_href = malloc( i_strlen +1);
memcpy( psz_href, psz_backup, i_strlen ); memcpy( psz_href, psz_backup, i_strlen );
psz_href[i_strlen] = '\0'; psz_href[i_strlen] = '\0';
psz_tmp = psz_href + (i_strlen-1); psz_tmp = psz_href + (i_strlen-1);
......
...@@ -2557,8 +2557,7 @@ static void ReadDir( intf_thread_t *p_intf ) ...@@ -2557,8 +2557,7 @@ static void ReadDir( intf_thread_t *p_intf )
continue; continue;
} }
psz_uri = (char *)malloc( sizeof(char)*i_size_entry); asprintf( &psz_uri, "%s/%s", p_sys->psz_current_dir, psz_entry );
sprintf( psz_uri, "%s/%s", p_sys->psz_current_dir, psz_entry );
if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) ) if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) )
{ {
......
...@@ -270,7 +270,7 @@ static char *get_file_perms(const struct stat st) ...@@ -270,7 +270,7 @@ static char *get_file_perms(const struct stat st)
{ {
char *psz_perm; char *psz_perm;
psz_perm = (char *) malloc(sizeof(char)*10); psz_perm = (char *) malloc(10);
strncpy( psz_perm, "----------", sizeof("----------")); strncpy( psz_perm, "----------", sizeof("----------"));
/* determine permission modes */ /* determine permission modes */
...@@ -658,7 +658,7 @@ void onAddCameraToPlaylist(GtkButton *button, gpointer user_data) ...@@ -658,7 +658,7 @@ void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
return; return;
for (i=0; i<11; i++) for (i=0; i<11; i++)
{ {
ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char)); ppsz_options[i] = (char *) malloc(VLC_MAX_MRL);
if (ppsz_options[i] == NULL) if (ppsz_options[i] == NULL)
{ {
for (i-=1; i>=0; i--) for (i-=1; i>=0; i--)
...@@ -1020,7 +1020,7 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data) ...@@ -1020,7 +1020,7 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
return; return;
for (i=0; i<3; i++) for (i=0; i<3; i++)
{ {
ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char)); ppsz_options[i] = (char *) malloc(VLC_MAX_MRL);
if (ppsz_options[i] == NULL) if (ppsz_options[i] == NULL)
{ {
for (i-=1; i>=0; i--) for (i-=1; i>=0; i--)
......
...@@ -1554,7 +1554,7 @@ void WizardDialog::Run() ...@@ -1554,7 +1554,7 @@ void WizardDialog::Run()
else if( ab < 0 ) else if( ab < 0 )
ab = 0; ab = 0;
psz_transcode = (char *)malloc( i_tr_size * sizeof(char) ); psz_transcode = (char *)malloc( i_tr_size );
strcpy( psz_transcode, "transcode{" ); strcpy( psz_transcode, "transcode{" );
if( vcodec != NULL ) if( vcodec != NULL )
......
...@@ -266,7 +266,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -266,7 +266,7 @@ static void Run( intf_thread_t *p_intf )
sprintf( psz_duration," " ); sprintf( psz_duration," " );
} }
psz_display = (char *)malloc( sizeof(char )* psz_display = (char *)malloc(
(strlen( p_input->psz_name ) + (strlen( p_input->psz_name ) +
MSTRTIME_MAX_SIZE + 2+6 + 10 +10 )); MSTRTIME_MAX_SIZE + 2+6 + 10 +10 ));
sprintf( psz_display,"%s %s", sprintf( psz_display,"%s %s",
......
...@@ -319,7 +319,7 @@ static char *assertUTF8URI( char *psz_name ) ...@@ -319,7 +319,7 @@ static char *assertUTF8URI( char *psz_name )
/* max. 3x for URI conversion (percent escaping) and /* max. 3x for URI conversion (percent escaping) and
8 bytes for "file://" and NULL-termination */ 8 bytes for "file://" and NULL-termination */
psz_ret = (char *)malloc( sizeof(char)*strlen(psz_name)*6*3+8 ); psz_ret = (char *)malloc( strlen(psz_name)*6*3+8 );
if( !psz_ret ) if( !psz_ret )
return NULL; return NULL;
...@@ -378,5 +378,5 @@ static char *assertUTF8URI( char *psz_name ) ...@@ -378,5 +378,5 @@ static char *assertUTF8URI( char *psz_name )
} }
*psz_d = '\0'; *psz_d = '\0';
return (char *)realloc( psz_ret, sizeof(char)*strlen( psz_ret ) + 1 ); return (char *)realloc( psz_ret, strlen( psz_ret ) + 1 );
} }
...@@ -198,7 +198,7 @@ static char *svg_GetTemplate( vlc_object_t *p_this ) ...@@ -198,7 +198,7 @@ static char *svg_GetTemplate( vlc_object_t *p_this )
msg_Dbg( p_this, "reading %ld bytes from template %s", msg_Dbg( p_this, "reading %ld bytes from template %s",
(unsigned long)s.st_size, psz_filename ); (unsigned long)s.st_size, psz_filename );
psz_template = malloc( ( s.st_size + 42 ) * sizeof( char ) ); psz_template = malloc( s.st_size + 42 );
if( !psz_template ) if( !psz_template )
{ {
fclose( file ); fclose( file );
...@@ -471,7 +471,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, ...@@ -471,7 +471,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
int length; int length;
char* psz_template = p_sys->psz_template; char* psz_template = p_sys->psz_template;
length = strlen( psz_string ) + strlen( psz_template ) + 42; length = strlen( psz_string ) + strlen( psz_template ) + 42;
p_svg->psz_text = malloc( ( length + 1 ) * sizeof( char ) ); p_svg->psz_text = malloc( length + 1 );
if( !p_svg->psz_text ) if( !p_svg->psz_text )
{ {
free( p_svg ); free( p_svg );
......
...@@ -289,7 +289,7 @@ static int Stress( vlc_object_t *p_this, char const *psz_cmd, ...@@ -289,7 +289,7 @@ static int Stress( vlc_object_t *p_this, char const *psz_cmd,
/* Allocate required data */ /* Allocate required data */
ppsz_name = malloc( MAXVAR * i_level * sizeof(char*) ); ppsz_name = malloc( MAXVAR * i_level * sizeof(char*) );
psz_blob = malloc( 20 * MAXVAR * i_level * sizeof(char) ); psz_blob = malloc( 20 * MAXVAR * i_level );
for( i = 0; i < MAXVAR * i_level; i++ ) for( i = 0; i < MAXVAR * i_level; i++ )
{ {
ppsz_name[i] = psz_blob + 20 * i; ppsz_name[i] = psz_blob + 20 * i;
......
...@@ -449,7 +449,7 @@ static char *xtag_slurp_to( XTagParser *parser, int good_end, int bad_end ) ...@@ -449,7 +449,7 @@ static char *xtag_slurp_to( XTagParser *parser, int good_end, int bad_end )
if( xi > 0 && xtag_cin (s[xi], good_end) ) if( xi > 0 && xtag_cin (s[xi], good_end) )
{ {
ret = malloc( (xi+1) * sizeof(char) ); ret = malloc( xi+1 );
strncpy( ret, s, xi ); strncpy( ret, s, xi );
ret[xi] = '\0'; ret[xi] = '\0';
parser->start = &s[xi]; parser->start = &s[xi];
...@@ -502,7 +502,7 @@ static char *xtag_slurp_quoted( XTagParser *parser ) ...@@ -502,7 +502,7 @@ static char *xtag_slurp_quoted( XTagParser *parser )
} }
} }
ret = malloc( (xi+1) * sizeof(char) ); ret = malloc( xi+1 );
strncpy( ret, s, xi ); strncpy( ret, s, xi );
ret[xi] = '\0'; ret[xi] = '\0';
parser->start = &s[xi]; parser->start = &s[xi];
...@@ -644,7 +644,7 @@ static XTag *xtag_parse_tag( XTagParser *parser ) ...@@ -644,7 +644,7 @@ static XTag *xtag_parse_tag( XTagParser *parser )
while (parser->end - s > 2) { while (parser->end - s > 2) {
if (strncmp( s, "]]>", 3 ) == 0) { if (strncmp( s, "]]>", 3 ) == 0) {
if ( !(tag = malloc( sizeof(*tag))) ) return NULL; if ( !(tag = malloc( sizeof(*tag))) ) return NULL;
if ( !(pcdata = malloc( sizeof(char)*(s - parser->start + 1))) ) if ( !(pcdata = malloc( s - parser->start + 1)) )
{ {
free( tag ); free( tag );
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment