]> git.sesse.net Git - vlc/commitdiff
Use calloc instead of malloc+memset.
authorRémi Duraffort <ivoire@videolan.org>
Fri, 12 Dec 2008 22:50:38 +0000 (23:50 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Fri, 12 Dec 2008 22:51:23 +0000 (23:51 +0100)
15 files changed:
modules/access/bda/bda.c
modules/access/dc1394.c
modules/access/dshow/dshow.cpp
modules/access/dvb/access.c
modules/access/ftp.c
modules/access/jack.c
modules/access/mms/mmsh.c
modules/access/mms/mmstu.c
modules/access/qtcapture.m
modules/access/screen/screen.c
modules/access/screen/win32.c
modules/access/v4l.c
modules/access/vcd/vcd.c
modules/audio_filter/converter/dtstospdif.c
modules/audio_filter/normvol.c

index c74e89ab4ef28b0f8826b3df34c434fd0a40efa9..e8c5e5ead88383908fa2daed23925904eab203bd 100644 (file)
@@ -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,
index abd1bed29540a3e9bbcea3944346ae675510d62c..18ad44d04b2331c7a98b6cdb7d34f70c32a7697c 100644 (file)
@@ -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 */
index f7c7e36756bfa3372be8338924c98083d1d7b611..62646a760bd3a5a34f1ca47d81fc6be6ccf2228c 100644 (file)
@@ -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 )
     {
index fd2ce25a1ad3adadf969a0aa1d6902d8b465e1fb..56239c944cf0513c9b77e5bc3c057032d22949ac 100644 (file)
@@ -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 );
 
index 8cb24f89b328219a1b8543f85706fcd2112608bb..e95a62ab186f5beb939b16d08ee2468a6fc260a3 100644 (file)
@@ -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;
index f40340ee8c87417bd3a6a8c4141d736ee84cf296..9809333d075c8e21bbef1a5a0a30af6dbfc99f08 100644 (file)
@@ -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 );
index 87bb09b4382ddddb8dd460d6f029338c874523f5..d69501702f8e26b00f58f6e20e9fe4abab0c967b 100644 (file)
@@ -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;
index 6961545785af0265f7b942491368cf5c49366df1..b1229e991d5df89ee0abf5f57171d6b6dbf72bfe 100644 (file)
@@ -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" );
 
index ce856aa0daf9cc2769ddf82d498012036a84a596..525dc4a8dd34a7e5488aae160a52318b1faf6d07 100644 (file)
@@ -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;
index 79e825552ed132a9a02efe9dbd072ad0d34e29dc..b66a10da5f8eef75a9abc24fda1c2283a3efa68f 100644 (file)
@@ -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 );
index 6ffa9f792d2f0320a996cfb77334707848537784..0d6c61bbc440ce2128d59ccfa134b3f8007ef07c 100644 (file)
@@ -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 );
index f9b24a56b8139f8c1b1cd16471cdd19ff5cf1df1..da9c7a8b0319dff19f40613516a290c62d069b64 100644 (file)
@@ -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 );
index 5059b776c40a5aa0f43860a4b2d494f88e0980aa..08d167e96a4ac983eb293e750a58bbdf4c4bf810 100644 (file)
@@ -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 */
index 9a6a8bf9911fc15e16779794aa77e27178f55982..70cb64f9e0af07232f9151244b8bc45c965393de 100644 (file)
@@ -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;
index a5420c168e0bc0103e8d22b27b6d15757fdfc239..ee6ddb3b86713863cbc14fc2e1d360b3649fb94c 100644 (file)
@@ -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 )