From 4d7d9ec2f853db188c7162578de87c8a3b13eaa0 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 14 Feb 2009 19:45:50 +0100 Subject: [PATCH] Use calloc when applicable (decoders). --- 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 fd5636efbf..022106dad5 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 d47a9146c1..0696eb1b8d 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 6206360bbe..157d9e808c 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 6af25e4d25..a6d8ef4156 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 1945f2aa76..aa1d1334c3 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 c0d70be94b..a7c6eafcc8 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 33e8a7d0de..5d25be9d51 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 */ -- 2.39.2