[vlc-devel] commit: libvlccore: the object counter is specific so misc/objects.c ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Aug 19 17:19:26 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Tue Aug 19 18:22:12 2008 +0300| [e1f1b1e2e69cde5937ed22465ebd29dfd4510b5e] | committer: Rémi Denis-Courmont 

libvlccore: the object counter is specific so misc/objects.c

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

 src/libvlc.h       |    3 ---
 src/misc/objects.c |    7 ++++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/libvlc.h b/src/libvlc.h
index 334b744..dfcaecf 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -154,9 +154,6 @@ typedef struct libvlc_global_data_t
 {
     VLC_COMMON_MEMBERS
 
-    /* Object structure data */
-    int                    i_counter;   ///< object counter
-
     module_bank_t *        p_module_bank; ///< The module bank
 
     char *                 psz_vlcpath;
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 96214c1..b7ed1e6 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -94,7 +94,8 @@ static void held_objects_destroy (void *);
 /*****************************************************************************
  * Local structure lock
  *****************************************************************************/
-static vlc_mutex_t     structure_lock;
+static vlc_mutex_t structure_lock;
+static unsigned    object_counter = 0;
 
 void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
                            int i_type, const char *psz_type )
@@ -148,7 +149,7 @@ void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
         p_libvlc_global = (libvlc_global_data_t *)p_new;
         p_new->p_libvlc = NULL;
 
-        p_libvlc_global->i_counter = 0;
+        object_counter = 0; /* reset */
         p_priv->next = p_priv->prev = p_new;
         vlc_mutex_init( &structure_lock );
 #ifdef LIBVLC_REFCHECK
@@ -194,7 +195,7 @@ void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
     p_priv->prev = vlc_internals (p_libvlc_global)->prev;
     vlc_internals (p_libvlc_global)->prev = p_new;
     vlc_internals (p_priv->prev)->next = p_new;
-    p_new->i_object_id = p_libvlc_global->i_counter++;
+    p_new->i_object_id = object_counter++; /* fetch THEN increment */
     vlc_mutex_unlock( &structure_lock );
 
     if( i_type == VLC_OBJECT_LIBVLC )




More information about the vlc-devel mailing list