]> git.sesse.net Git - vlc/commitdiff
Remove MALLOC_NULL and use calloc when needed.
authorRémi Duraffort <ivoire@videolan.org>
Sun, 2 Nov 2008 12:00:01 +0000 (13:00 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 2 Nov 2008 12:00:01 +0000 (13:00 +0100)
include/vlc_common.h
src/input/input.c
src/misc/messages.c

index a637bad3c4f37b8a5a29ddbd5092ba92cf6b569e..7060cb5c4180fa7835f7250797c33954d6d26339 100644 (file)
@@ -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)
index 7e4c8f920c990fdbda9f0c775a437b0f35a7de5d..a147b2ea6a2195d7c9863f338a0def44fbf0fabe 100644 (file)
@@ -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 */
index 29031f042d6fe22344c54fa29a3f4270546f9468..c26fccaabe7359294b092c4e51fda225d08cb45a 100644 (file)
@@ -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 );
     }