[vlc-commits] voc: use vlc_obj_malloc()

Rémi Denis-Courmont git at videolan.org
Thu May 3 14:28:23 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May  3 12:04:53 2018 +0300| [0aae30a79618c8e452dbe3b40062bef59f38abb5] | committer: Rémi Denis-Courmont

voc: use vlc_obj_malloc()

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

 modules/demux/voc.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/modules/demux/voc.c b/modules/demux/voc.c
index b450228bee..5298b23462 100644
--- a/modules/demux/voc.c
+++ b/modules/demux/voc.c
@@ -37,14 +37,13 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
 
 vlc_module_begin ()
     set_description( N_("VOC demuxer") )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_DEMUX )
     set_capability( "demux", 10 )
-    set_callbacks( Open, Close )
+    set_callbacks( Open, NULL )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -76,7 +75,6 @@ static const char ct_header[] = "Creative Voice File\x1a";
 static int Open( vlc_object_t * p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
-    demux_sys_t *p_sys;
     const uint8_t *p_buf;
     uint16_t    i_data_offset, i_version;
 
@@ -108,8 +106,8 @@ static int Open( vlc_object_t * p_this )
     if( vlc_stream_Read( p_demux->s, NULL, i_data_offset ) < i_data_offset )
         return VLC_EGENERIC;
 
-    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
-    if( p_sys == NULL )
+    demux_sys_t *p_sys = vlc_obj_malloc( p_this, sizeof (*p_sys) );
+    if( unlikely(p_sys == NULL) )
         return VLC_ENOMEM;
 
     p_sys->i_silence_countdown = p_sys->i_block_start = p_sys->i_block_end =
@@ -122,6 +120,7 @@ static int Open( vlc_object_t * p_this )
     es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
+    p_demux->p_sys = p_sys;
 
     return VLC_SUCCESS;
 }
@@ -522,16 +521,6 @@ static int Demux( demux_t *p_demux )
 }
 
 /*****************************************************************************
- * Close: frees unused data
- *****************************************************************************/
-static void Close ( vlc_object_t * p_this )
-{
-    demux_sys_t *p_sys  = ((demux_t *)p_this)->p_sys;
-
-    free( p_sys );
-}
-
-/*****************************************************************************
  * Control:
  *****************************************************************************/
 static int Control( demux_t *p_demux, int i_query, va_list args )



More information about the vlc-commits mailing list