[vlc-devel] [PATCH] libvlc: help debug object references remaining in debug builds

Steve Lhomme robux4 at videolabs.io
Fri Oct 23 16:09:27 CEST 2015


---
 src/libvlc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/libvlc.c b/src/libvlc.c
index 34824da..7e7b097 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -553,7 +553,19 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
 
     vlc_ExitDestroy( &priv->exit );
 
+#ifndef NDEBUG
+    vlc_object_internals_t *internals = vlc_internals(p_libvlc);
+    int refcount = atomic_load(&internals->refs);
+    if (refcount > 1) {
+        while (internals) {
+            vlc_Log(NULL, VLC_MSG_DBG, "libvlc", NULL, 0, "libvlc_InternalDestroy", "remaining ref %s count:%d", internals->psz_name ? internals->psz_name : "???", internals->refs);
+            internals = internals->first;
+        }
+    }
+    assert( refcount == 1 );
+#else
     assert( atomic_load(&(vlc_internals(p_libvlc)->refs)) == 1 );
+#endif
     vlc_object_release( p_libvlc );
 }
 
-- 
2.6.2



More information about the vlc-devel mailing list