]> git.sesse.net Git - vlc/commitdiff
Use calloc instead of malloc+memset.
authorRémi Duraffort <ivoire@videolan.org>
Sat, 13 Dec 2008 15:24:24 +0000 (16:24 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Sat, 13 Dec 2008 15:25:35 +0000 (16:25 +0100)
14 files changed:
modules/access/dvb/en50221.c
modules/access_filter/bandwidth.c
modules/access_filter/dump.c
modules/access_output/bonjour.c
modules/audio_output/pulse.c
modules/codec/avcodec/encoder.c
modules/codec/avcodec/video.c
modules/codec/cc.c
modules/codec/cdg.c
modules/codec/csri.c
modules/misc/rtsp.c
modules/mux/mpeg/csa.c
modules/mux/ogg.c
modules/stream_out/transcode.c

index f8c1dadc644b7bbd07d7c495599f00c125929ba6..4b9ff7cee379bf8444bc97d24030fb757585903f 100644 (file)
@@ -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 );
 }
index 995ee8aced0754879ac46b7971e2cf287ad51b5a..43bce412c4a2f85fd8754abc9ff7668e984236f9 100644 (file)
@@ -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;
 }
+
index 932e919033185b2b50d38c343a926dca7f483abd..37bb33d70b823eff02874c1cdccf57710a2383ae 100644 (file)
@@ -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)
index 6092c09000903edd679eb599b3570c62e46c0413..89ce76178b398571acbd5b29d5ae955195482a04 100644 (file)
@@ -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 );
index 848f72ae78e04c08d7d3bd8cf812b58ff2d85f1d..4ce9ccbf14821517fb56dcb39599fa0f75a3016c 100644 (file)
@@ -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");
 
index 19519a1960a42e991b5f60c41e29a8681021c79c..557b84bba228c6388585ff3f99510b75b34fa334 100644 (file)
@@ -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;
 
index 5c63fa262fae3de4951768bebc89d2ba166f1368..fffa7546fe472d2f20238b42853f9cc290b04271 100644 (file)
@@ -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;
index e00afb3742d90947be39d6658afe7e7b17d338e9..af479914cbc19fa559a5f127e2a0ee115aad70b5 100644 (file)
@@ -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;
 
index 3269061fbbed3769472ac7dbdac607e93595f7f4..7dca2a581c7497b961f001b6fc2a941a86f24534 100644 (file)
@@ -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
index dfcd13b242dae4153331b4e47ad98672377d90b0..8d3f9e3a123a8eb1b4274facb5b1ec85a24404e5 100644 (file)
@@ -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;
index 5583c6499fd6205be3d33632ae6eb8e4801ceefb..262cbc70c2add68ec619fdb7b6f2b9878d33dc7b 100644 (file)
@@ -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;
index 9550297473671bf4dc0a0572cf9f193e486fb302..99ae905b57c1e9efb7744c45a78fec4c0f95582c 100644 (file)
@@ -66,16 +66,13 @@ 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 ) );
 }
 
 /*****************************************************************************
  * csa_Delete:
  *****************************************************************************/
-void   csa_Delete( csa_t *c )
+void csa_Delete( csa_t *c )
 {
     free( c );
 }
index 26ddeee4ca78e988d8e89e2634a857415052ff17..b767ed634e6fe9f2657bb896331bb2a81ba98523 100644 (file)
@@ -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 );
index 4a7680e902c949c5c22aa530e18baf3237b4415a..2b8cbdbf9f92000f365f0c4106798c07d14dfdec 100644 (file)
@@ -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;