]> git.sesse.net Git - vlc/blobdiff - src/misc/messages.c
Remove useless test before freeing something.
[vlc] / src / misc / messages.c
index 07953379dd6fcf27060fbc6430e226f7f26d9402..3fc0f03c3d0aa43821629c2a47fa9e4fb4034c51 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <stdarg.h>                                       /* va_list for BSD */
 
 #include <errno.h>                                                  /* errno */
 
+#ifdef WIN32
+#   include <vlc_network.h>          /* 'net_strerror' and 'WSAGetLastError' */
+#endif
+
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>                                   /* close(), write() */
 #endif
@@ -76,11 +84,12 @@ static void PrintMsg ( vlc_object_t *, msg_item_t * );
 void __msg_Create( vlc_object_t *p_this )
 {
     int i;
-    vlc_mutex_init( p_this, &(p_this->p_libvlc->msg_bank.lock) );
+    vlc_mutex_init( (vlc_object_t *)NULL,
+                    &(p_this->p_libvlc->msg_bank.lock) );
 
     for( i = 0; i < 2; i++ )
     {
-         vlc_mutex_init( p_this, &QUEUE(i).lock );
+         vlc_mutex_init( (vlc_object_t *)NULL, &QUEUE(i).lock );
          QUEUE(i).b_overflow = VLC_FALSE;
          QUEUE(i).i_id = i;
          QUEUE(i).i_start = 0;
@@ -180,7 +189,7 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
             if( QUEUE(i).pp_sub[j] == p_sub )
             {
                 REMOVE_ELEM( QUEUE(i).pp_sub, QUEUE(i).i_sub, j );
-                if( p_sub ) free( p_sub );
+                free( p_sub );
             }
         }
         vlc_mutex_unlock( & QUEUE(i).lock );
@@ -297,7 +306,12 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
 
     if( p_this == NULL )
     {
+#ifndef NDEBUG
+        if( i_type == VLC_MSG_DBG )
+            return;
+#endif
         utf8_vfprintf( stderr, psz_format, _args );
+        fputc ('\n', stderr);
         return;
     }
 
@@ -309,7 +323,8 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
     /* Expand %m to strerror(errno) - only once */
     char buf[strlen( psz_format ) + 2001], *ptr;
     strcpy( buf, psz_format );
-    ptr = psz_format = buf;
+    ptr = (char*)buf;
+    psz_format = (const char*) buf;
 
     for( ;; )
     {
@@ -416,7 +431,7 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
                           p_obj->psz_header );
             }
         }
-        if( psz_old ) free( psz_old );
+        free( psz_old );
         p_obj = p_obj->p_parent;
     }
 
@@ -496,12 +511,9 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
 
     if( p_queue->b_overflow )
     {
-        if( p_item->psz_module )
-            free( p_item->psz_module );
-        if( p_item->psz_msg )
-            free( p_item->psz_msg );
-        if( p_item->psz_header )
-            free( p_item->psz_header );
+        free( p_item->psz_module );
+        free( p_item->psz_msg );
+        free( p_item->psz_header );
     }
 
     vlc_mutex_unlock ( &p_queue->lock );
@@ -544,12 +556,9 @@ static void FlushMsg ( msg_queue_t *p_queue )
          i_index != i_stop;
          i_index = (i_index+1) % VLC_MSG_QSIZE )
     {
-        if( p_queue->msg[i_index].psz_msg )
-            free( p_queue->msg[i_index].psz_msg );
-        if( p_queue->msg[i_index].psz_module )
-            free( p_queue->msg[i_index].psz_module );
-        if( p_queue->msg[i_index].psz_header )
-            free( p_queue->msg[i_index].psz_header );
+        free( p_queue->msg[i_index].psz_msg );
+        free( p_queue->msg[i_index].psz_module );
+        free( p_queue->msg[i_index].psz_header );
     }
 
     /* Update the new start value */