[vlc-commits] rawvideo: use vlc_obj_calloc() and simplify

Rémi Denis-Courmont git at videolan.org
Fri Sep 25 15:53:52 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Sep 25 16:29:53 2020 +0300| [0863fd5ae5581352b4a37e1172328e06f189ffcd] | committer: Rémi Denis-Courmont

rawvideo: use vlc_obj_calloc() and simplify

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

 modules/codec/rawvideo.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index c43932d437..43f864ad29 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -54,7 +54,6 @@ typedef struct
  ****************************************************************************/
 static int  OpenDecoder   ( vlc_object_t * );
 static int  OpenPacketizer( vlc_object_t * );
-static void CloseCommon   ( vlc_object_t * );
 
 /*****************************************************************************
  * Module descriptor
@@ -64,12 +63,12 @@ vlc_module_begin ()
     set_capability( "video decoder", 50 )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_VCODEC )
-    set_callbacks( OpenDecoder, CloseCommon )
+    set_callback( OpenDecoder )
 
     add_submodule ()
     set_description( N_("Pseudo raw video packetizer") )
     set_capability( "packetizer", 100 )
-    set_callbacks( OpenPacketizer, CloseCommon )
+    set_callback( OpenPacketizer )
 vlc_module_end ()
 
 /**
@@ -90,7 +89,7 @@ static int OpenCommon( decoder_t *p_dec )
     }
 
     /* Allocate the memory needed to store the decoder's structure */
-    decoder_sys_t *p_sys = calloc(1, sizeof(*p_sys));
+    decoder_sys_t *p_sys = vlc_obj_calloc(VLC_OBJECT(p_dec), 1, sizeof(*p_sys));
     if( unlikely(p_sys == NULL) )
         return VLC_ENOMEM;
 
@@ -325,12 +324,3 @@ static int OpenPacketizer( vlc_object_t *p_this )
     }
     return ret;
 }
-
-/**
- * Common deinitialization
- */
-static void CloseCommon( vlc_object_t *p_this )
-{
-    decoder_t *p_dec = (decoder_t*)p_this;
-    free( p_dec->p_sys );
-}



More information about the vlc-commits mailing list