From a06942a143460d18bb0b84e3338fc16a8387b355 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 24 Aug 2013 07:52:52 +0200 Subject: [PATCH] mp4 mux: simplify box*new --- 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 7b13f33ddc..11b73d623e 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; } -- 2.39.2