[vlc-commits] mp4 mux: simplify box*new

Rafaël Carré git at videolan.org
Sat Aug 24 18:24:34 CEST 2013


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sat Aug 24 07:52:52 2013 +0200| [a06942a143460d18bb0b84e3338fc16a8387b355] | committer: Rafaël Carré

mp4 mux: simplify box*new

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

 modules/mux/mp4.c |   28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/mux/mp4.c b/modules/mux/mp4.c
index 7b13f33..11b73d6 100644
--- a/modules/mux/mp4.c
+++ b/modules/mux/mp4.c
@@ -1953,32 +1953,26 @@ static void bo_add_descr( bo_t *p_bo, uint8_t tag, uint32_t size )
 
 static bo_t * box_new( const char *fcc )
 {
-    bo_t *box;
+    bo_t *box = malloc( sizeof( *box ) );
+    if (!box)
+        return NULL;
 
-    if( ( box = malloc( sizeof( bo_t ) ) ) )
-    {
-        bo_init( box );
+    bo_init( box );
 
-        bo_add_32be  ( box, 0 );
-        bo_add_fourcc( box, fcc );
-    }
+    bo_add_32be  ( box, 0 );
+    bo_add_fourcc( box, fcc );
 
     return box;
 }
 
 static bo_t * box_full_new( const char *fcc, uint8_t v, uint32_t f )
 {
-    bo_t *box;
+    bo_t *box = box_new( fcc );
+    if (!box)
+        return NULL;
 
-    if( ( box = malloc( sizeof( bo_t ) ) ) )
-    {
-        bo_init( box );
-
-        bo_add_32be  ( box, 0 );
-        bo_add_fourcc( box, fcc );
-        bo_add_8     ( box, v );
-        bo_add_24be  ( box, f );
-    }
+    bo_add_8     ( box, v );
+    bo_add_24be  ( box, f );
 
     return box;
 }



More information about the vlc-commits mailing list