[vlc-commits] au: use vlc_obj_malloc()

Rémi Denis-Courmont git at videolan.org
Thu May 3 10:52:55 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May  3 11:51:19 2018 +0300| [f2ebba3de5fc0872ab79e1432476b9a0204cd6f4] | committer: Rémi Denis-Courmont

au: use vlc_obj_malloc()

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

 modules/demux/au.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/modules/demux/au.c b/modules/demux/au.c
index 67f0cba208..ed34ee8ebe 100644
--- a/modules/demux/au.c
+++ b/modules/demux/au.c
@@ -43,14 +43,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_("AU demuxer") )
     set_capability( "demux", 10 )
-    set_callbacks( Open, Close )
+    set_callbacks( Open, NULL )
     add_shortcut( "au" )
 vlc_module_end ()
 
@@ -103,7 +102,6 @@ static int Control ( demux_t *, int i_query, va_list args );
 static int Open( vlc_object_t *p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
-    demux_sys_t *p_sys;
 
     uint8_t      hdr[20];
     const uint8_t *p_peek;
@@ -132,7 +130,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_sys = malloc( sizeof (*p_sys) );
+    demux_sys_t *p_sys = vlc_obj_malloc( p_this, sizeof (*p_sys) );
     if( unlikely(p_sys == NULL) )
         return VLC_ENOMEM;
 
@@ -144,11 +142,11 @@ static int Open( vlc_object_t *p_this )
     {
 #if (SSIZE_MAX <= INT32_MAX)
         if( p_sys->i_header_size > SSIZE_MAX )
-            goto error;
+            return VLC_EGENERIC;
 #endif
         size_t skip = p_sys->i_header_size - 24;
         if( vlc_stream_Read( p_demux->s, NULL, skip ) < (ssize_t)skip )
-            goto error;
+            return VLC_EGENERIC;
     }
 
     /* init fmt */
@@ -264,13 +262,13 @@ static int Open( vlc_object_t *p_this )
     if( i_cat == AU_CAT_UNKNOWN || i_cat == AU_CAT_ADPCM )
     {
         msg_Err( p_demux, "unsupported codec/type (Please report it)" );
-        goto error;
+        return VLC_EGENERIC;
     }
 
     if( p_sys->fmt.audio.i_rate == 0 )
     {
         msg_Err( p_demux, "invalid samplerate: 0" );
-        goto error;
+        return VLC_EGENERIC;
     }
 
     /* add the es */
@@ -296,9 +294,6 @@ static int Open( vlc_object_t *p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     return VLC_SUCCESS;
-error:
-    free( p_sys );
-    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -335,17 +330,6 @@ static int Demux( demux_t *p_demux )
 }
 
 /*****************************************************************************
- * Close: frees unused data
- *****************************************************************************/
-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 );
-}
-
-/*****************************************************************************
  * Control:
  *****************************************************************************/
 static int Control( demux_t *p_demux, int i_query, va_list args )



More information about the vlc-commits mailing list