]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Fix multiple deallocation (three deallocation for the same varaible that's a bit...
[vlc] / src / libvlc.c
index 00c26adb53607a8703f4bd5ecd55ca1d61d28d7c..45fa3a0e5e1a0d08030bce4439d4e5af6793f1d8 100644 (file)
@@ -151,10 +151,10 @@ void *vlc_hold (gc_object_t * p_gc)
 
 #if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
     refs = __sync_add_and_fetch (&p_gc->refs, 1);
-#elif defined (WIN32) && defined (__GNUC__)
-    refs = __builtin_choose_expr (sizeof (uintptr_t) == 4,
-               InterlockedIncrement (&p_gc->refs),
-               InterlockedIncrement64 (&p_gc->refs));
+#elif defined (WIN64)
+    refs = InterlockedIncrement64 (&p_gc->refs);
+#elif defined (WIN32)
+    refs = InterlockedIncrement (&p_gc->refs);
 #elif defined(__APPLE__)
     refs = OSAtomicIncrement32Barrier((int*)&p_gc->refs);
 #else
@@ -178,10 +178,10 @@ void vlc_release (gc_object_t *p_gc)
 
 #if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
     refs = __sync_sub_and_fetch (&p_gc->refs, 1);
-#elif defined (WIN32) && defined (__GNUC__)
-    refs = __builtin_choose_expr (sizeof (uintptr_t) == 4,
-               InterlockedDecrement (&p_gc->refs),
-               InterlockedDecrement64 (&p_gc->refs));
+#elif defined (WIN64)
+    refs = InterlockedDecrement64 (&p_gc->refs);
+#elif defined (WIN32)
+    refs = InterlockedDecrement (&p_gc->refs);
 #elif defined(__APPLE__)
     refs = OSAtomicDecrement32Barrier((int*)&p_gc->refs);
 #else
@@ -228,7 +228,7 @@ static int  VerboseCallback( vlc_object_t *, char const *,
 
 static void InitDeviceValues( libvlc_int_t * );
 
-vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
+static vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
 
 /**
  * Allocate a libvlc instance, initialize global data if needed
@@ -488,7 +488,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     size_t module_count;
     module_t **list = module_list_get( &module_count );
     module_list_free( list );
-    msg_Dbg( p_libvlc, "module bank initialized (%u modules)", module_count );
+    msg_Dbg( p_libvlc, "module bank initialized (%zu modules)", module_count );
 
     /* Check for help on modules */
     if( (p_tmp = config_GetPsz( p_libvlc, "module" )) )
@@ -744,11 +744,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( priv->b_color )
         priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
 
-    /*
-     * Output messages that may still be in the queue
-     */
-    msg_Flush( p_libvlc );
-
     if( !config_GetInt( p_libvlc, "fpu" ) )
         cpu_flags &= ~CPU_CAPABILITY_FPU;
 
@@ -793,7 +788,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /*
      * Choose the best memcpy module
      */
-    priv->p_memcpy_module = module_need( p_libvlc, "memcpy", "$memcpy", 0 );
+    priv->p_memcpy_module = module_need( p_libvlc, "memcpy", "$memcpy", false );
 
     priv->b_stats = config_GetInt( p_libvlc, "stats" ) > 0;
     priv->i_timers = 0;
@@ -888,10 +883,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             *psz_parser = '\0';
             psz_parser++;
         }
-        psz_temp = (char *)malloc( strlen(psz_module) + sizeof(",none") );
-        if( psz_temp )
+        if( asprintf( &psz_temp, "%s,none", psz_module ) != -1)
         {
-            sprintf( psz_temp, "%s,none", psz_module );
             libvlc_InternalAddIntf( p_libvlc, psz_temp );
             free( psz_temp );
         }
@@ -929,7 +922,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     }
 #endif
 
-    if( config_GetInt( p_libvlc, "file-logging" ) > 0 )
+    if( (config_GetInt( p_libvlc, "file-logging" ) > 0) &&
+        !config_GetInt( p_libvlc, "syslog" ) )
     {
         libvlc_InternalAddIntf( p_libvlc, "logger,none" );
     }
@@ -1141,7 +1135,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
     }
     vlc_mutex_unlock( &global_lock );
 
-    msg_Flush( p_libvlc );
     msg_Destroy( p_libvlc );
 
     /* Destroy mutexes */