Commit f6d9ebe6 authored by Rémi Duraffort's avatar Rémi Duraffort

Use calloc instead of malloc+memset.

parent 4b090cbd
......@@ -316,12 +316,10 @@ static int Open( vlc_object_t *p_this )
p_access->info.b_eof = false;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = (access_sys_t *)malloc( sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
for( int i = 0; i < i_param_count; i++ )
{
snprintf( psz_full_name, 128, "%s-%s\0", psz_module,
......
......@@ -225,10 +225,9 @@ static int Open( vlc_object_t *p_this )
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( demux_sys_t ) );
memset( &fmt, 0, sizeof( es_format_t ) );
/* DEFAULTS */
......
......@@ -579,10 +579,9 @@ static int DemuxOpen( vlc_object_t *p_this )
access_sys_t *p_sys;
int i;
p_sys = (access_sys_t *)malloc( sizeof( access_sys_t ) );
p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
p_demux->p_sys = (demux_sys_t *)p_sys;
if( CommonOpen( p_this, p_sys, true ) != VLC_SUCCESS )
......@@ -663,10 +662,9 @@ static int AccessOpen( vlc_object_t *p_this )
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
p_access->p_sys = p_sys = (access_sys_t *)malloc( sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
if( CommonOpen( p_this, p_sys, false ) != VLC_SUCCESS )
{
......
......@@ -327,12 +327,10 @@ static int Open( vlc_object_t *p_this )
access_InitFields( p_access );
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
/* Create all variables */
VarInit( p_access );
......
......@@ -367,10 +367,9 @@ static int OutOpen( vlc_object_t *p_this )
sout_access_out_t *p_access = (sout_access_out_t *)p_this;
access_sys_t *p_sys;
p_sys = malloc( sizeof( *p_sys ) );
if( p_sys == NULL )
p_sys = calloc( 1, sizeof( *p_sys ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( *p_sys ) );
/* Init p_access */
p_sys->fd_data = -1;
......
......@@ -142,9 +142,8 @@ static int Open( vlc_object_t *p_this )
/* Allocate structure */
p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
if( p_sys == NULL )
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( demux_sys_t ) );
/* Parse MRL */
Parse( p_demux );
......
......@@ -93,14 +93,12 @@ int MMSHOpen( access_t *p_access )
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->i_proto= MMS_PROTO_HTTP;
p_sys->fd = -1;
p_sys->i_start= 0;
/* Handle proxy */
p_sys->b_proxy = false;
......
......@@ -112,9 +112,8 @@ int MMSTUOpen( access_t *p_access )
p_access->info.b_eof = false;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys ) return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->i_timeout = var_CreateGetInteger( p_access, "mms-timeout" );
......
......@@ -210,10 +210,10 @@ static int Open( vlc_object_t *p_this )
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( !p_sys ) return VLC_ENOMEM;
p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( demux_sys_t ) );
memset( &fmt, 0, sizeof( es_format_t ) );
QTCaptureDeviceInput * input = nil;
......
......@@ -142,8 +142,9 @@ static int Open( vlc_object_t *p_this )
/* Fill p_demux field */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
/* Update default_pts to a suitable value for screen access */
var_Create( p_demux, "screen-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
......
......@@ -55,10 +55,9 @@ int screen_InitCapture( demux_t *p_demux )
screen_data_t *p_data;
int i_chroma, i_bits_per_pixel;
p_sys->p_data = p_data = malloc( sizeof( screen_data_t ) );
p_sys->p_data = p_data = calloc( sizeof( 1, screen_data_t ) );
if( !p_data )
return VLC_ENOMEM;
memset( p_data, 0, sizeof( screen_data_t ) );
/* Get the device context for the whole screen */
p_data->hdc_src = CreateDC( "DISPLAY", NULL, NULL, NULL );
......
......@@ -333,8 +333,9 @@ static int Open( vlc_object_t *p_this )
p_demux->info.i_update = 0;
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
var_Create( p_demux, "v4l-audio", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_demux, "v4l-audio", &val );
......
......@@ -154,8 +154,9 @@ static int Open( vlc_object_t *p_this )
p_access->info.b_eof = false;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
memset( p_sys, 0, sizeof( access_sys_t ) );
p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
if( !p_sys )
goto error;
p_sys->vcddev = vcddev;
/* We read the Table Of Content information */
......
......@@ -89,11 +89,9 @@ static int Create( vlc_object_t *p_this )
}
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_filter->p_sys == NULL )
p_filter->p_sys = calloc( 1, sizeof(struct aout_filter_sys_t) );
if( !p_filter->p_sys )
return VLC_ENOMEM;
memset( p_filter->p_sys, 0, sizeof(struct aout_filter_sys_t) );
p_filter->p_sys->p_buf = 0;
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 1;
......
......@@ -139,15 +139,13 @@ static int Open( vlc_object_t *p_this )
if( p_sys->f_max <= 0 ) p_sys->f_max = 0.01;
/* We need to store (nb_buffers+1)*nb_channels floats */
p_sys->p_last = malloc( sizeof( float ) * (i_channels) *
(p_filter->p_sys->i_nb + 2) );
p_sys->p_last = calloc( i_channels * (p_filter->p_sys->i_nb + 2), sizeof(float) );
if( !p_sys->p_last )
{
free( p_sys );
return VLC_ENOMEM;
}
memset( p_sys->p_last, 0 ,sizeof( float ) * (i_channels) *
(p_filter->p_sys->i_nb + 2) );
return VLC_SUCCESS;
}
......@@ -169,10 +167,9 @@ static int Open( vlc_object_t *p_this )
struct aout_filter_sys_t *p_sys = p_filter->p_sys;
pf_sum = malloc( sizeof(float) * i_channels );
pf_sum = calloc( i_channels, sizeof(float) );
if( !pf_sum )
return;
memset( pf_sum, 0, sizeof(float) * i_channels );
pf_gain = malloc( sizeof(float) * i_channels );
if( !pf_gain )
......
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