[vlc-devel] commit: Use calloc when applicable (decoders). (Laurent Aimar )

git version control git at videolan.org
Sun Feb 15 00:44:14 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Feb 14 19:45:50 2009 +0100| [4d7d9ec2f853db188c7162578de87c8a3b13eaa0] | committer: Laurent Aimar 

Use calloc when applicable (decoders).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4d7d9ec2f853db188c7162578de87c8a3b13eaa0
---

 modules/codec/faad.c      |    3 +--
 modules/codec/fake.c      |    5 +----
 modules/codec/flac.c      |    3 +--
 modules/codec/kate.c      |    7 ++++---
 modules/codec/realaudio.c |    3 +--
 modules/codec/theora.c    |    3 +--
 modules/codec/vorbis.c    |    3 +--
 7 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index fd5636e..022106d 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -123,8 +123,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* 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 = malloc( sizeof(*p_sys) ) ) == NULL )
         return VLC_ENOMEM;
 
     /* Open a faad context */
diff --git a/modules/codec/fake.c b/modules/codec/fake.c
index d47a914..0696eb1 100644
--- a/modules/codec/fake.c
+++ b/modules/codec/fake.c
@@ -143,12 +143,9 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_dec->p_sys = (decoder_sys_t *)malloc( sizeof( decoder_sys_t ) );
+    p_dec->p_sys = calloc( 1, sizeof( *p_dec->p_sys ) );
     if( !p_dec->p_sys )
-    {
         return VLC_ENOMEM;
-    }
-    memset( p_dec->p_sys, 0, sizeof( decoder_sys_t ) );
 
     psz_file = var_CreateGetNonEmptyStringCommand( p_dec, "fake-file" );
     if( !psz_file )
diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 6206360..157d9e8 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -214,8 +214,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
 
     /* 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 = malloc(sizeof(*p_sys)) ) == NULL )
         return VLC_ENOMEM;
 
     /* Misc init */
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index 6af25e4..a6d8ef4 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -360,8 +360,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         DecodeBlock;
 
     /* 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 = malloc(sizeof(*p_sys)) ) == NULL )
         return VLC_ENOMEM;
 
     vlc_mutex_init( &p_sys->lock );
@@ -426,8 +425,10 @@ static int OpenDecoder( vlc_object_t *p_this )
 
 #endif
 
+    es_format_Init( &p_dec->fmt_out, SPU_ES, 0 );
+
     /* add the decoder to the global list */
-    decoder_t **list = ( decoder_t** ) realloc( kate_decoder_list, (kate_decoder_list_size+1) * sizeof( decoder_t* ));
+    decoder_t **list = realloc( kate_decoder_list, (kate_decoder_list_size+1) * sizeof( *list ));
     if( list )
     {
         list[ kate_decoder_list_size++ ] = p_dec;
diff --git a/modules/codec/realaudio.c b/modules/codec/realaudio.c
index 1945f2a..aa1d133 100644
--- a/modules/codec/realaudio.c
+++ b/modules/codec/realaudio.c
@@ -200,10 +200,9 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
+    p_dec->p_sys = p_sys = calloc( 1, sizeof( *p_sys ) );
     if( !p_sys )
         return VLC_ENOMEM;
-    memset( p_sys, 0, sizeof(decoder_sys_t) );
 
     /* Flavor for SIPR codecs */
     p_sys->i_codec_flavor = -1;
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index c0d70be..a7c6eaf 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -139,8 +139,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
 
     /* 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 = malloc(sizeof(*p_sys)) ) == NULL )
         return VLC_ENOMEM;
     p_dec->p_sys->b_packetizer = false;
 
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index 33e8a7d..5d25be9 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -235,8 +235,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
 
     /* 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 = malloc( sizeof(*p_sys) ) ) == NULL )
         return VLC_ENOMEM;
 
     /* Misc init */




More information about the vlc-devel mailing list