]> git.sesse.net Git - vlc/commitdiff
Prepare to privatize some members of VLC_COMMON_MEMBERS
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 16 Aug 2007 15:43:28 +0000 (15:43 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 16 Aug 2007 15:43:28 +0000 (15:43 +0000)
include/vlc_common.h
src/libvlc.h
src/misc/objects.c

index 8ef6ff2dd769924672358f39ac19191e21d9f6ce..93759eec443fadec5a2199deea5ac54da7b7943d 100644 (file)
@@ -525,6 +525,8 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *,      /* variable's object */
 
 #include "vlc_threads.h"
 
+typedef struct vlc_object_internals_t vlc_object_internals_t;
+
 /*****************************************************************************
  * Common structure members
  *****************************************************************************/
@@ -535,6 +537,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *,      /* variable's object */
  * these members are common for all vlc objects                             \
  */                                                                         \
 /**@{*/                                                                     \
+    vlc_object_internals_t *p_internals;                                    \
     int   i_object_id;                                                      \
     int   i_object_type;                                                    \
     const char *psz_object_type;                                            \
index 1019056c52707571ea7bc7028f268ba0b910f32c..9aedae50f208455b0036b269118587392f22a3bb 100644 (file)
@@ -83,4 +83,15 @@ static inline libvlc_global_data_t *__vlc_global( vlc_object_t *p_this )
 extern uint32_t cpu_flags;
 uint32_t CPUCapabilities( void );
 
+/* Private LibVLC data for each objects */
+struct vlc_object_internals_t
+{
+
+};
+
+static inline vlc_object_internals_t *vlc_internals( vlc_object_t *obj )
+{
+    return obj->p_internals;
+}
+
 #endif
index 0ba4961582930e769732740d7519c33f64817a68..b33447d57a3bd2824da6ae05d5d8c5b75226414e 100644 (file)
@@ -88,23 +88,30 @@ static void           ListChildren  ( vlc_list_t *, vlc_object_t *, int );
  * Local structure lock
  *****************************************************************************/
 static vlc_mutex_t    structure_lock;
+static vlc_object_internals_t global_internals;
 
 vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
                                  int i_type, const char *psz_type )
 {
-    vlc_object_t * p_new = NULL;
+    vlc_object_t *p_new;
+    vlc_object_internals_t *p_priv;
 
     if( i_type == VLC_OBJECT_GLOBAL )
     {
         p_new = p_this;
+        p_priv = &global_internals;
+        memset( p_priv, 0, sizeof( *p_priv ) );
     }
     else
     {
-        p_new = malloc( i_size );
-        if( !p_new ) return NULL;
-        memset( p_new, 0, i_size );
+        p_priv = calloc( 1, sizeof( *p_priv ) + i_size );
+        if( p_priv == NULL )
+            return NULL;
+
+        p_new = (vlc_object_t *)(p_priv + 1);
     }
 
+    p_new->p_internals = p_priv;
     p_new->i_object_type = i_type;
     p_new->psz_object_type = psz_type;
 
@@ -132,7 +139,7 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
     if( !p_new->p_vars )
     {
         if( i_type != VLC_OBJECT_GLOBAL )
-            free( p_new );
+            free( p_priv );
         return NULL;
     }
 
@@ -336,6 +343,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
  *****************************************************************************/
 void __vlc_object_destroy( vlc_object_t *p_this )
 {
+    vlc_object_internals_t *p_priv = vlc_internals( p_this );
     int i_delay = 0;
 
     if( p_this->i_children )
@@ -426,10 +434,7 @@ void __vlc_object_destroy( vlc_object_t *p_this )
 
     /* global is not dynamically allocated by vlc_object_create */
     if( p_this->i_object_type != VLC_OBJECT_GLOBAL )
-    {
-        free( p_this );
-        p_this = NULL;
-    }
+        free( p_priv );
 }