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

Use calloc instead of malloc+memset.

parent ea4894d2
......@@ -1368,9 +1368,7 @@ static void ConditionalAccessOpen( access_t * p_access, int i_session_id )
p_sys->p_sessions[i_session_id - 1].pf_handle = ConditionalAccessHandle;
p_sys->p_sessions[i_session_id - 1].pf_close = ConditionalAccessClose;
p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(system_ids_t));
memset( p_sys->p_sessions[i_session_id - 1].p_sys, 0,
sizeof(system_ids_t) );
p_sys->p_sessions[i_session_id - 1].p_sys = calloc( 1, sizeof(system_ids_t) );
APDUSend( p_access, i_session_id, AOT_CA_INFO_ENQ, NULL, 0 );
}
......@@ -1500,8 +1498,7 @@ static void DateTimeOpen( access_t * p_access, int i_session_id )
p_sys->p_sessions[i_session_id - 1].pf_handle = DateTimeHandle;
p_sys->p_sessions[i_session_id - 1].pf_manage = DateTimeManage;
p_sys->p_sessions[i_session_id - 1].pf_close = DateTimeClose;
p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(date_time_t));
memset( p_sys->p_sessions[i_session_id - 1].p_sys, 0, sizeof(date_time_t) );
p_sys->p_sessions[i_session_id - 1].p_sys = calloc( 1, sizeof(date_time_t) );
DateTimeSend( p_access, i_session_id );
}
......
......@@ -87,11 +87,10 @@ static int Open (vlc_object_t *obj)
access->pf_control = Control;
access->info = src->info;
access_sys_t *p_sys = access->p_sys = malloc (sizeof (*p_sys));
if (p_sys == NULL)
access_sys_t *p_sys = access->p_sys = calloc( 1, sizeof (*p_sys) );
if( !p_sys )
return VLC_ENOMEM;
memset (p_sys, 0, sizeof (*p_sys));
p_sys->bandwidth = var_CreateGetInteger (access, "access-bandwidth");
p_sys->last_time = mdate ();
......@@ -175,3 +174,4 @@ static int Seek (access_t *access, int64_t offset)
access->info = src->info;
return ret;
}
......@@ -109,10 +109,9 @@ static int Open (vlc_object_t *obj)
access->pf_control = Control;
access->info = src->info;
access_sys_t *p_sys = access->p_sys = malloc (sizeof (*p_sys));
if (p_sys == NULL)
access_sys_t *p_sys = access->p_sys = calloc( 1, sizeof (*p_sys) );
if( !p_sys )
return VLC_ENOMEM;
memset (p_sys, 0, sizeof (*p_sys));
# ifndef UNDER_CE
if ((p_sys->stream = tmpfile ()) == NULL)
......
......@@ -192,16 +192,12 @@ void *bonjour_start_service( vlc_object_t *p_log, const char *psz_stype,
const char *psz_name, int i_port, char *psz_txt )
{
int err;
bonjour_t *p_sys;
p_sys = (bonjour_t *)malloc( sizeof(*p_sys) );
bonjour_t* p_sys = calloc( 1, sizeof(*p_sys) );
if( p_sys == NULL )
return NULL;
memset( p_sys, 0, sizeof(*p_sys) );
p_sys->p_log = p_log;
p_sys->i_port = i_port;
p_sys->psz_name = avahi_strdup( psz_name );
p_sys->psz_stype = avahi_strdup( psz_stype );
......
......@@ -118,10 +118,9 @@ static int Open ( vlc_object_t *p_this )
struct pa_channel_map map;
/* Allocate structures */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
p_aout->output.p_sys = p_sys = calloc( 1, sizeof( aout_sys_t ) );
if( p_sys == NULL )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof( aout_sys_t ) );
PULSE_DEBUG( "Pulse start initialization");
......
......@@ -263,9 +263,8 @@ int OpenEncoder( vlc_object_t *p_this )
}
/* Allocate the memory needed to store the encoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
if( ( p_sys = calloc( 1, sizeof(encoder_sys_t) ) ) == NULL )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof(encoder_sys_t) );
p_enc->p_sys = p_sys;
p_sys->p_codec = p_codec;
......
......@@ -183,12 +183,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
vlc_value_t val;
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ) ) == NULL )
return VLC_ENOMEM;
}
memset( p_sys, 0, sizeof(decoder_sys_t) );
p_dec->p_sys->p_context = p_context;
p_dec->p_sys->p_codec = p_codec;
......
......@@ -199,14 +199,11 @@ static int Open( vlc_object_t *p_this )
p_dec->pf_decode_sub = Decode;
/* Allocate the memory needed to store the decoder's structure */
p_dec->p_sys = p_sys = malloc( sizeof( *p_sys ) );
p_dec->p_sys = p_sys = calloc( 1, sizeof( *p_sys ) );
if( p_sys == NULL )
return VLC_ENOMEM;
/* init of p_sys */
memset( p_sys, 0, sizeof( *p_sys ) );
p_sys->i_block = 0;
p_sys->i_field = i_field;
p_sys->i_channel = i_channel;
......
......@@ -101,14 +101,11 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
/* Allocate the memory needed to store the decoder's structure */
p_dec->p_sys = p_sys = malloc(sizeof(decoder_sys_t));
p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) );
if( !p_sys )
return VLC_ENOMEM;
/* Init */
memset( p_sys, 0, sizeof(*p_sys) );
p_sys->i_offseth = 0;
p_sys->i_offsetv = 0;
p_sys->p_screen = p_sys->screen;
/* Set output properties
......
......@@ -120,10 +120,9 @@ static int Create( vlc_object_t *p_this )
p_dec->pf_decode_sub = DecodeBlock;
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
p_dec->p_sys = p_sys = calloc( 1, sizeof( decoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( &p_sys->fmt_cached, 0, sizeof( p_sys->fmt_cached ) );
p_sys->p_stream_ext = p_stream_ext;
p_sys->pf_push_packet = p_stream_ext->push_packet;
......
......@@ -368,14 +368,13 @@ static void Close( vlc_object_t * p_this )
static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
input_item_t *p_item )
{
vod_sys_t *p_sys = p_vod->p_sys;
vod_media_t *p_media = malloc( sizeof(vod_media_t) );
int i;
vod_sys_t *p_sys = p_vod->p_sys;
vod_media_t *p_media = calloc( 1, sizeof(vod_media_t) );
if( !p_media )
return NULL;
memset( p_media, 0, sizeof(vod_media_t) );
p_media->id = p_sys->i_media_id++;
TAB_INIT( p_media->i_es, p_media->es );
p_media->psz_mux = NULL;
......@@ -498,11 +497,10 @@ static void MediaDel( vod_t *p_vod, vod_media_t *p_media )
static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
{
media_es_t *p_es = malloc( sizeof(media_es_t) );
char *psz_urlc;
if( !p_es ) return VLC_ENOMEM;
memset( p_es, 0, sizeof(media_es_t) );
media_es_t *p_es = calloc( 1, sizeof(media_es_t) );
if( !p_es )
return VLC_ENOMEM;
free( p_media->psz_mux );
p_media->psz_mux = NULL;
......@@ -896,10 +894,10 @@ static void* CommandThread( vlc_object_t *p_this )
****************************************************************************/
static rtsp_client_t *RtspClientNew( vod_media_t *p_media, char *psz_session )
{
rtsp_client_t *p_rtsp = malloc( sizeof(rtsp_client_t) );
rtsp_client_t *p_rtsp = calloc( 1, sizeof(rtsp_client_t) );
if( !p_rtsp ) return NULL;
memset( p_rtsp, 0, sizeof(rtsp_client_t) );
if( !p_rtsp )
return NULL;
p_rtsp->es = 0;
p_rtsp->psz_session = psz_session;
......
......@@ -66,10 +66,7 @@ static void csa_BlockCypher( uint8_t kk[57], uint8_t bd[8], uint8_t ib[8] );
*****************************************************************************/
csa_t *csa_New( void )
{
csa_t *c = malloc( sizeof( csa_t ) );
memset( c, 0, sizeof( csa_t ) );
return c;
return calloc( 1, sizeof( csa_t ) );
}
/*****************************************************************************
......
......@@ -354,13 +354,12 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
case VLC_FOURCC( 'W', 'M', 'V', '2' ):
case VLC_FOURCC( 'W', 'M', 'V', '3' ):
case VLC_FOURCC( 'S', 'N', 'O', 'W' ):
p_stream->p_oggds_header = malloc( sizeof(oggds_header_t) );
p_stream->p_oggds_header = calloc( 1, sizeof(oggds_header_t) );
if( !p_stream->p_oggds_header )
{
free( p_stream );
return VLC_ENOMEM;
}
memset( p_stream->p_oggds_header, 0, sizeof(oggds_header_t) );
p_stream->p_oggds_header->i_packet_type = PACKET_TYPE_HEADER;
memcpy( p_stream->p_oggds_header->stream_type, "video", 5 );
......@@ -476,13 +475,12 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
switch( p_stream->i_fourcc )
{
case VLC_FOURCC( 's', 'u','b', 't' ):
p_stream->p_oggds_header = malloc( sizeof(oggds_header_t) );
p_stream->p_oggds_header = calloc( 1, sizeof(oggds_header_t) );
if( !p_stream->p_oggds_header )
{
free( p_stream );
return VLC_ENOMEM;
}
memset( p_stream->p_oggds_header, 0, sizeof(oggds_header_t) );
p_stream->p_oggds_header->i_packet_type = PACKET_TYPE_HEADER;
memcpy( p_stream->p_oggds_header->stream_type, "text", 4 );
......
......@@ -693,10 +693,9 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_stream_id_t *id;
id = malloc( sizeof( sout_stream_id_t ) );
id = calloc( 1, sizeof( sout_stream_id_t ) );
if( !id )
goto error;
memset( id, 0, sizeof(sout_stream_id_t) );
id->id = NULL;
id->p_decoder = 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