]> git.sesse.net Git - vlc/blobdiff - include/vlc_variables.h
var_AcquireMutex: enforce constant mutex name
[vlc] / include / vlc_variables.h
index ecd997e382ac216bb5ecbd4f3a60e656f71842f7..432691d2c62d05fbca10b78165adac8943e2d629 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined( __LIBVLC__ )
-  #error You are not libvlc or one of its plugins. You cannot include this file
-#endif
+#ifndef VLC_VARIABLES_H
+#define VLC_VARIABLES_H 1
 
-#ifndef _VLC_VARIABLES_H
-#define _VLC_VARIABLES_H 1
+/**
+ * \file
+ * This file defines functions and structures for dynamic variables in vlc
+ */
 
 /**
  * \defgroup variables Variables
 
 #define VLC_VAR_INHERITVALUE        0x0030
 #define VLC_VAR_TRIGGER_CALLBACKS   0x0035
+
+#define VLC_VAR_SETISCOMMAND        0x0040
 /**@}*/
 
 /*****************************************************************************
@@ -128,6 +131,23 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
 VLC_EXPORT( int, __var_Command, ( vlc_object_t *, const char *, const char *, const char *, char ** ) );
 
 VLC_EXPORT( vlc_mutex_t *, var_AcquireMutex, ( const char * ) );
+#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.