[vlc-commits] aiff: use vlc_obj_calloc()
Rémi Denis-Courmont
git at videolan.org
Thu May 3 10:49:12 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 3 11:47:45 2018 +0300| [6302901cc68acd906a37c2cc358d6ea8ef762b2f] | committer: Rémi Denis-Courmont
aiff: use vlc_obj_calloc()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6302901cc68acd906a37c2cc358d6ea8ef762b2f
---
modules/demux/aiff.c | 33 ++++++++-------------------------
1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/modules/demux/aiff.c b/modules/demux/aiff.c
index 3689016a5e..0090ef059a 100644
--- a/modules/demux/aiff.c
+++ b/modules/demux/aiff.c
@@ -42,14 +42,13 @@
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
vlc_module_begin ()
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
set_description( N_("AIFF demuxer" ) )
set_capability( "demux", 10 )
- set_callbacks( Open, Close )
+ set_callbacks( Open, NULL )
add_shortcut( "aiff" )
vlc_module_end ()
@@ -117,7 +116,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
/* Fill p_demux field */
- demux_sys_t *p_sys = calloc( 1, sizeof (*p_sys) );
+ demux_sys_t *p_sys = vlc_obj_calloc( p_this, 1, sizeof (*p_sys) );
es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
p_sys->i_time = 0;
p_sys->i_ssnd_pos = -1;
@@ -125,7 +124,7 @@ static int Open( vlc_object_t *p_this )
for( ;; )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
- goto error;
+ return VLC_EGENERIC;
uint32_t i_data_size = GetDWBE( &p_peek[4] );
uint64_t i_chunk_size = UINT64_C( 8 ) + i_data_size + ( i_data_size & 1 );
@@ -136,7 +135,7 @@ static int Open( vlc_object_t *p_this )
if( !memcmp( p_peek, "COMM", 4 ) )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 18+8 ) < 18+8 )
- goto error;
+ return VLC_EGENERIC;
p_sys->fmt.audio.i_channels = GetWBE( &p_peek[8] );
p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] );
@@ -149,7 +148,7 @@ static int Open( vlc_object_t *p_this )
else if( !memcmp( p_peek, "SSND", 4 ) )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 8+8 ) < 8+8 )
- goto error;
+ return VLC_EGENERIC;
p_sys->i_ssnd_pos = vlc_stream_Tell( p_demux->s );
p_sys->i_ssnd_size = i_data_size;
@@ -176,7 +175,7 @@ static int Open( vlc_object_t *p_this )
if( vlc_stream_Read( p_demux->s, NULL, i_req ) != i_req )
{
msg_Warn( p_demux, "incomplete file" );
- goto error;
+ return VLC_EGENERIC;
}
}
}
@@ -190,7 +189,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->i_ssnd_fsize <= 0 || p_sys->fmt.audio.i_rate == 0 )
{
msg_Err( p_demux, "invalid audio parameters" );
- goto error;
+ return VLC_EGENERIC;
}
if( p_sys->i_ssnd_size <= 0 )
@@ -203,7 +202,7 @@ static int Open( vlc_object_t *p_this )
if( vlc_stream_Seek( p_demux->s, p_sys->i_ssnd_start ) )
{
msg_Err( p_demux, "cannot seek to data chunk" );
- goto error;
+ return VLC_EGENERIC;
}
/* */
@@ -214,25 +213,9 @@ static int Open( vlc_object_t *p_this )
p_demux->p_sys = p_sys;
return VLC_SUCCESS;
-
-error:
- free( p_sys );
- return VLC_EGENERIC;
}
/*****************************************************************************
- * Close
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
- demux_t *p_demux = (demux_t*)p_this;
- demux_sys_t *p_sys = p_demux->p_sys;
-
- free( p_sys );
-}
-
-
-/*****************************************************************************
* Demux:
*****************************************************************************/
static int Demux( demux_t *p_demux )
More information about the vlc-commits
mailing list