[vlc-commits] objects: remove constant (1) member

Rémi Denis-Courmont git at videolan.org
Sun Mar 17 02:39:17 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 16 17:38:35 2019 +0200| [efd4a8472ea89318723c15291a399cbe11bd7194] | committer: Rémi Denis-Courmont

objects: remove constant (1) member

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

 src/libvlc.c         |  2 --
 src/misc/objects.c   | 37 +++++--------------------------------
 src/misc/variables.h |  2 --
 3 files changed, 5 insertions(+), 36 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index a140aa3c00..9b6da1e32d 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -68,7 +68,6 @@
 
 #include "libvlc.h"
 #include "playlist_legacy/playlist_internal.h"
-#include "misc/variables.h"
 
 #include <vlc_vlm.h>
 
@@ -460,7 +459,6 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
         }
     }
 #endif
-    assert( atomic_load(&(vlc_internals(p_libvlc)->refs)) == 1 );
     vlc_object_delete(p_libvlc);
 }
 
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 7db15b6b6d..b10f626a7b 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -105,14 +105,12 @@ static void PrintObjectPrefix(vlc_object_t *obj, FILE *output, bool last)
 
 static void PrintObject(vlc_object_t *obj, FILE *output)
 {
-    vlc_object_internals_t *priv = vlc_internals(obj);
-
     int canc = vlc_savecancel ();
 
     PrintObjectPrefix(obj, output, true);
-    fprintf(output, "\xE2\x94\x80\xE2\x94%c\xE2\x95\xB4%p %s, %u refs\n",
+    fprintf(output, "\xE2\x94\x80\xE2\x94%c\xE2\x95\xB4%p %s\n",
            ObjectHasChildLocked(obj) ? 0xAC : 0x80,
-           (void *)obj, vlc_object_typename(obj), atomic_load(&priv->refs));
+           (void *)obj, vlc_object_typename(obj));
 
     vlc_restorecancel (canc);
 }
@@ -177,7 +175,6 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
     priv->var_root = NULL;
     vlc_mutex_init (&priv->var_lock);
     vlc_cond_init (&priv->var_wait);
-    atomic_init (&priv->refs, 1);
     priv->pf_destructor = NULL;
     priv->resources = NULL;
 
@@ -295,43 +292,19 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this, const char *psz_name )
 void (vlc_object_delete)(vlc_object_t *obj)
 {
     vlc_object_internals_t *priv = vlc_internals(obj);
-    unsigned refs = atomic_load_explicit(&priv->refs, memory_order_relaxed);
-
-    /* Fast path */
-    while (refs > 1)
-    {
-        if (atomic_compare_exchange_weak_explicit(&priv->refs, &refs, refs - 1,
-                                   memory_order_release, memory_order_relaxed))
-            return; /* There are still other references to the object */
-
-        assert (refs > 0);
-    }
-
     vlc_object_t *parent = vlc_object_parent(obj);
 
     if (unlikely(parent == NULL))
     {   /* Destroying the root object */
-        refs = atomic_fetch_sub_explicit(&priv->refs, 1, memory_order_relaxed);
-        assert (refs == 1); /* nobody to race against in this case */
         vlc_object_destroy (obj);
         return;
     }
 
-    /* Slow path */
     vlc_mutex_lock(&tree_lock);
-    refs = atomic_fetch_sub_explicit(&priv->refs, 1, memory_order_release);
-    assert (refs > 0);
-
-    if (likely(refs == 1))
-        /* Detach from parent to protect against vlc_object_find_name() */
-        vlc_list_remove(&priv->list);
+    /* Detach from parent to protect against vlc_object_find_name() */
+    vlc_list_remove(&priv->list);
     vlc_mutex_unlock(&tree_lock);
-
-    if (likely(refs == 1))
-    {
-        atomic_thread_fence(memory_order_acquire);
-        vlc_object_destroy (obj);
-    }
+    vlc_object_destroy (obj);
 }
 
 void vlc_object_vaLog(vlc_object_t *obj, int prio, const char *module,
diff --git a/src/misc/variables.h b/src/misc/variables.h
index ce3f27de31..a63ec730f2 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -24,7 +24,6 @@
 # define LIBVLC_VARIABLES_H 1
 
 # include <stdalign.h>
-# include <stdatomic.h>
 # include <vlc_list.h>
 
 struct vlc_res;
@@ -46,7 +45,6 @@ struct vlc_object_internals
     vlc_cond_t      var_wait;
 
     /* Objects management */
-    atomic_uint     refs;
     vlc_destructor_t pf_destructor;
 
     /* Objects tree structure */



More information about the vlc-commits mailing list