[vlc-devel] commit: Check for leaked objects while we still can ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Aug 31 16:00:38 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Aug 31 17:03:27 2008 +0300| [7dfd64360f509aeebf1fba6f1713f873b71e3e8c] | committer: Rémi Denis-Courmont
Check for leaked objects while we still can
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7dfd64360f509aeebf1fba6f1713f873b71e3e8c
---
src/misc/objects.c | 51 +++++++++++++++++++++++++--------------------------
1 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 790a126..20deed4 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -307,30 +307,6 @@ static void vlc_object_destroy( vlc_object_t *p_this )
free( p_this->psz_header );
-#ifndef NDEBUG
- if( VLC_OBJECT(p_this->p_libvlc) == p_this )
- {
- /* Test for leaks */
- vlc_object_t *leaked = p_priv->next;
- while( leaked != p_this )
- {
- /* We are leaking this object */
- fprintf( stderr,
- "ERROR: leaking object (id:%i, type:%s, name:%s)\n",
- leaked->i_object_id, leaked->psz_object_type,
- leaked->psz_object_name );
- /* Dump object to ease debugging */
- vlc_object_dump( leaked );
- fflush(stderr);
- leaked = vlc_internals (leaked)->next;
- }
-
- if( p_priv->next != p_this )
- /* Dump libvlc object to ease debugging */
- vlc_object_dump( p_this );
- }
-#endif
-
if( p_this->p_libvlc == NULL )
/* We are the global object ... no need to lock. */
vlc_mutex_destroy( &structure_lock );
@@ -743,6 +719,29 @@ void __vlc_object_release( vlc_object_t *p_this )
if( b_should_destroy )
{
+#ifndef NDEBUG
+ if( VLC_OBJECT(p_this->p_libvlc) == p_this )
+ {
+ /* Test for leaks */
+ vlc_object_t *leaked = internals->next;
+ while( leaked != p_this )
+ {
+ /* We are leaking this object */
+ fprintf( stderr,
+ "ERROR: leaking object (id:%i, type:%s, name:%s)\n",
+ leaked->i_object_id, leaked->psz_object_type,
+ leaked->psz_object_name );
+ /* Dump object to ease debugging */
+ vlc_object_dump( leaked );
+ fflush(stderr);
+ leaked = vlc_internals (leaked)->next;
+ }
+
+ if( internals->next != p_this )
+ /* Dump libvlc object to ease debugging */
+ vlc_object_dump( p_this );
+ }
+#endif
/* Remove the object from object list
* so that it cannot be encountered by vlc_object_get() */
vlc_internals (internals->next)->prev = internals->prev;
@@ -1102,11 +1101,11 @@ void vlc_list_release( vlc_list_t *p_list )
*****************************************************************************/
void __vlc_object_dump( vlc_object_t *p_this )
{
- vlc_mutex_lock( &structure_lock );
char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
psz_foo[0] = '|';
+
+ vlc_assert_locked( &structure_lock );
DumpStructure( p_this, 0, psz_foo );
- vlc_mutex_unlock( &structure_lock );
}
/* Following functions are local */
More information about the vlc-devel
mailing list