From 9ee5f674f8ea0ab5e50fbb34345e2c63eeaa4025 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Wed, 10 Feb 2010 09:02:57 +0100 Subject: [PATCH] Use calloc. --- modules/codec/zvbi.c | 6 ++---- modules/demux/mp4/mp4.c | 3 +-- modules/misc/svg.c | 6 ++---- modules/video_filter/chain.c | 4 +--- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c index 50c4edf7d2..2efa7bc4b2 100644 --- a/modules/codec/zvbi.c +++ b/modules/codec/zvbi.c @@ -206,10 +206,9 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; p_dec->pf_decode_sub = Decode; - p_sys = p_dec->p_sys = malloc( sizeof(decoder_sys_t) ); + p_sys = p_dec->p_sys = calloc( 1, sizeof(decoder_sys_t) ); if( p_sys == NULL ) return VLC_ENOMEM; - memset( p_sys, 0, sizeof(decoder_sys_t) ); p_sys->i_key[0] = p_sys->i_key[1] = p_sys->i_key[2] = '*' - '0'; p_sys->b_update = false; @@ -246,8 +245,7 @@ static int Open( vlc_object_t *p_this ) /* Create the var on vlc_global. */ p_sys->i_wanted_page = var_CreateGetInteger( p_dec, "vbi-page" ); - var_AddCallback( p_dec, "vbi-page", - RequestPage, p_sys ); + var_AddCallback( p_dec, "vbi-page", RequestPage, p_sys ); /* Check if the Teletext track has a known "initial page". */ if( p_sys->i_wanted_page == 100 && p_dec->fmt_in.subs.teletext.i_magazine != -1 ) diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index f2140d26b3..9561c81777 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -313,8 +313,7 @@ static int Open( vlc_object_t * p_this ) p_demux->pf_control = Control; /* create our structure that will contains all data */ - 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 ) ); /* Now load all boxes ( except raw data ) */ if( ( p_sys->p_root = MP4_BoxGetRoot( p_demux->s ) ) == NULL ) diff --git a/modules/misc/svg.c b/modules/misc/svg.c index 31e3f1e6e0..7c5ad64b89 100644 --- a/modules/misc/svg.c +++ b/modules/misc/svg.c @@ -195,14 +195,13 @@ static char *svg_GetTemplate( vlc_object_t *p_this ) msg_Dbg( p_this, "reading %ld bytes from template %s", (unsigned long)s.st_size, psz_filename ); - psz_template = malloc( s.st_size + 42 ); + psz_template = calloc( 1, s.st_size + 42 ); if( !psz_template ) { fclose( file ); free( psz_filename ); return NULL; } - memset( psz_template, 0, s.st_size + 1 ); if(! fread( psz_template, s.st_size, 1, file ) ) { msg_Dbg( p_this, "No data read from template." ); @@ -469,13 +468,12 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, int length; char* psz_template = p_sys->psz_template; length = strlen( psz_string ) + strlen( psz_template ) + 42; - p_svg->psz_text = malloc( length + 1 ); + p_svg->psz_text = calloc( 1, length + 1 ); if( !p_svg->psz_text ) { free( p_svg ); return VLC_ENOMEM; } - memset( p_svg->psz_text, 0, length + 1 ); snprintf( p_svg->psz_text, length, psz_template, psz_string ); } p_svg->i_width = p_sys->i_width; diff --git a/modules/video_filter/chain.c b/modules/video_filter/chain.c index bd7549d12b..6642dd0539 100644 --- a/modules/video_filter/chain.c +++ b/modules/video_filter/chain.c @@ -91,12 +91,10 @@ static int Activate( vlc_object_t *p_this ) if( !b_chroma && !b_resize ) return VLC_EGENERIC; - p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) ); + p_sys = p_filter->p_sys = calloc( 1, sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; - memset( p_sys, 0, sizeof( *p_sys ) ); - p_sys->p_chain = filter_chain_New( p_filter, "video filter2", false, BufferAllocationInit, NULL, p_filter ); if( !p_sys->p_chain ) { -- 2.39.5