[vlc-devel] commit: Remove MALLOC_NULL and use calloc when needed. ( Rémi Duraffort )

git version control git at videolan.org
Sun Nov 2 13:00:23 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Nov  2 13:00:01 2008 +0100| [b6366fc0b0182bd552ccb0276998601ed133f1ec] | committer: Rémi Duraffort 

Remove MALLOC_NULL and use calloc when needed.

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

 include/vlc_common.h |    5 +----
 src/input/input.c    |    5 +++--
 src/misc/messages.c  |    4 +++-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index a637bad..7060cb5 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -603,10 +603,7 @@ static inline uint8_t clip_uint8_vlc( int32_t a )
     else           return a;
 }
 
-/* Malloc with automatic error */
-#define MALLOC_NULL( var, type ) do { var = (type*)malloc( sizeof( type) ); \
-                                   if( !var ) return NULL; } while(0)
-
+/* Free and set set the variable to NULL */
 #define FREENULL(a) do { free( a ); a = NULL; } while(0)
 
 #define EMPTY_STR(str) (!str || !*str)
diff --git a/src/input/input.c b/src/input/input.c
index 7e4c8f9..a147b2e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -161,8 +161,9 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     stats_TimerStart( p_input, psz_timer_name,
         STATS_TIMER_INPUT_LAUNCHING );
 
-    MALLOC_NULL( p_input->p, input_thread_private_t );
-    memset( p_input->p, 0, sizeof( input_thread_private_t ) );
+    p_input->p = calloc( 1, sizeof( input_thread_private_t ) );
+    if( !p_input->p )
+        return NULL;
 
     /* One "randomly" selected input thread is responsible for computing
      * the global stats. Check if there is already someone doing this */
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 29031f0..c26fcca 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -595,7 +595,9 @@ static msg_context_t* GetContext(void)
     msg_context_t *p_ctx = vlc_threadvar_get( &msg_context );
     if( p_ctx == NULL )
     {
-        MALLOC_NULL( p_ctx, msg_context_t );
+        p_ctx = malloc( sizeof( msg_context_t ) );
+        if( !p_ctx )
+            return NULL;
         p_ctx->psz_message = NULL;
         vlc_threadvar_set( &msg_context, p_ctx );
     }




More information about the vlc-devel mailing list