Changeset 23293def20be7820c9b891c4e219e2cf71f6d636

Show
Ignore:
Timestamp:
01/06/08 15:50:01 (6 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212328201 +0300
git-parent:

[6391721b5a50240dfc9da84d4bac3ba9759f33df]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212328201 +0300
Message:

Look for reference leaks. I found none, though.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/misc/objects.c

    r24f4104 r23293de  
    8989    vlc_object_t *obj; 
    9090} held_list_t; 
     91static void held_objects_destroy (void *); 
    9192#endif 
    9293 
     
    153154#ifndef NDEBUG 
    154155        /* TODO: use the destruction callback to track ref leaks */ 
    155         vlc_threadvar_create( &held_objects, NULL ); 
     156        vlc_threadvar_create( &held_objects, held_objects_destroy ); 
    156157#endif 
    157158    } 
     
    385386        vlc_mutex_destroy( &structure_lock ); 
    386387#ifndef NDEBUG 
     388        held_objects_destroy( vlc_threadvar_get( &held_objects ) ); 
    387389        vlc_threadvar_delete( &held_objects ); 
    388390#endif 
     
    797799    /* Update the list of referenced objects */ 
    798800    /* Using TLS, so no need to lock */ 
     801    /* The following line may leak memory if a thread leaks objects. */ 
    799802    held_list_t *newhead = malloc (sizeof (*newhead)); 
    800803    held_list_t *oldhead = vlc_threadvar_get (&held_objects); 
     
    15951598        fprintf (stderr, "Too many reference errors!\n"); 
    15961599} 
     1600 
     1601static void held_objects_destroy (void *data) 
     1602{ 
     1603    held_list_t *hl = vlc_threadvar_get (&held_objects); 
     1604    vlc_object_t *caller = vlc_threadobj (); 
     1605 
     1606    while (hl != NULL) 
     1607    { 
     1608        held_list_t *buf = hl->next; 
     1609        vlc_object_t *obj = hl->obj; 
     1610 
     1611        fprintf (stderr, "The %s %s thread object leaked a reference to...\n" 
     1612                         "the %s %s object.\n", 
     1613                 caller && caller->psz_object_name 
     1614                     ? caller->psz_object_name : "unnamed", 
     1615                 caller ? caller->psz_object_type : "main", 
     1616                 obj->psz_object_name ? obj->psz_object_name : "unnamed", 
     1617                 obj->psz_object_type); 
     1618        free (hl); 
     1619        hl = buf; 
     1620    } 
     1621} 
    15971622#endif