[vlc-devel] commit: Remove slow and leaking var_AcquireMutex ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Oct 5 11:41:27 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Oct  5 12:40:24 2008 +0300| [6e2ed233dd40ccc93a20e6fdfbdfaca8cf9b8e51] | committer: Rémi Denis-Courmont 

Remove slow and leaking var_AcquireMutex

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

 include/vlc_variables.h |   19 -------------------
 src/libvlccore.sym      |    1 -
 src/misc/threads.c      |   41 -----------------------------------------
 3 files changed, 0 insertions(+), 61 deletions(-)

diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 9015b0b..b43a44d 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -133,25 +133,6 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
 #define var_Command(a,b,c,d,e) __var_Command( VLC_OBJECT( a ), b, c, d, e )
 VLC_EXPORT( int, __var_Command, ( vlc_object_t *, const char *, const char *, const char *, char ** ) );
 
-VLC_EXPORT( vlc_mutex_t *, var_AcquireMutex, ( const char * ) LIBVLC_USED );
-#ifdef __GNUC__
-static
-__attribute__((unused))
-__attribute__((noinline))
-__attribute__((error("variable mutex name leaks memory at run-time")))
-const char *nonconst_mutex_name( const char *str )
-{
-    return str;
-}
-
-# define check_named_mutex( m ) \
-    (__builtin_constant_p(m) ? m : nonconst_mutex_name(m))
-#else
-# define check_named_mutex( m ) (m)
-#endif
-
-#define var_AcquireMutex( n ) var_AcquireMutex(check_named_mutex(n))
-
 /**
  * __var_Create() with automatic casting.
  */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 300e5dd..badcf07 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -411,7 +411,6 @@ utf8_scandir
 utf8_stat
 utf8_unlink
 utf8_vfprintf
-var_AcquireMutex
 __var_AddCallback
 __var_Change
 __var_Command
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 8d7f9ba..19f4ded 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -45,17 +45,6 @@
 static vlc_threadvar_t cancel_key;
 #endif
 
-static struct
-{
-   vlc_dictionary_t list;
-   vlc_mutex_t      lock;
-} named_mutexes = {
-    { 0, NULL, },
-#ifdef LIBVLC_USE_PTHREAD
-    PTHREAD_MUTEX_INITIALIZER,
-#endif
-};
-
 #ifdef HAVE_EXECINFO_H
 # include <execinfo.h>
 #endif
@@ -167,8 +156,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
     switch (fdwReason)
     {
         case DLL_PROCESS_ATTACH:
-            vlc_dictionary_init (&named_mutexes.list, 0);
-            vlc_mutex_init (&named_mutexes.lock);
             vlc_mutex_init (&super_mutex);
             vlc_threadvar_create (&cancel_key, free);
             break;
@@ -176,8 +163,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
         case DLL_PROCESS_DETACH:
             vlc_threadvar_delete( &cancel_key );
             vlc_mutex_destroy (&super_mutex);
-            vlc_mutex_destroy (&named_mutexes.lock);
-            vlc_dictionary_clear (&named_mutexes.list);
             break;
     }
     return TRUE;
@@ -1060,29 +1045,3 @@ void vlc_control_cancel (int cmd, ...)
     va_end (ap);
 #endif
 }
-
-
-#undef var_AcquireMutex
-/**
- * Finds a process-wide mutex, creates it if needed, and locks it.
- * Unlock with vlc_mutex_unlock().
- * FIXME: This is very inefficient, this is not memory-safe and this leaks
- * memory. Use static locks instead.
- */
-vlc_mutex_t *var_AcquireMutex( const char *name )
-{
-    vlc_mutex_t *lock;
-
-    vlc_mutex_lock (&named_mutexes.lock);
-    lock = vlc_dictionary_value_for_key (&named_mutexes.list, name);
-    if (lock == kVLCDictionaryNotFound)
-    {
-        lock = malloc (sizeof (*lock));
-        vlc_mutex_init (lock);
-        vlc_dictionary_insert (&named_mutexes.list, name, lock);
-    }
-    vlc_mutex_unlock (&named_mutexes.lock);
-
-    vlc_mutex_lock (lock);
-    return lock;
-}




More information about the vlc-devel mailing list