Changeset 070e3454880e849f3ebca21d5f803cdd13351049
- Timestamp:
- 31/05/08 22:51:19
(6 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1212267079 +0300
- git-parent:
[90fd835fb4e43fcc2cb0b80d988b253843c4c548]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1212267079 +0300
- Message:
Keep track of object held by threads
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r90fd835 |
r070e345 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2004-2008 the VideoLAN team |
|---|
| 5 | | * $Id$ |
|---|
| 6 | 5 | * |
|---|
| 7 | 6 | * Authors: Samuel Hocevar <sam@zoy.org> |
|---|
| … | … | |
| 82 | 81 | static void vlc_object_destroy( vlc_object_t *p_this ); |
|---|
| 83 | 82 | static void vlc_object_detach_unlocked (vlc_object_t *p_this); |
|---|
| | 83 | |
|---|
| | 84 | #ifndef NDEBUG |
|---|
| | 85 | static vlc_threadvar_t held_objects; |
|---|
| | 86 | typedef struct held_list_t |
|---|
| | 87 | { |
|---|
| | 88 | struct held_list_t *next; |
|---|
| | 89 | vlc_object_t *obj; |
|---|
| | 90 | } held_list_t; |
|---|
| | 91 | #endif |
|---|
| 84 | 92 | |
|---|
| 85 | 93 | /***************************************************************************** |
|---|
| … | … | |
| 143 | 151 | p_priv->next = p_priv->prev = p_new; |
|---|
| 144 | 152 | vlc_mutex_init( &structure_lock ); |
|---|
| | 153 | #ifndef NDEBUG |
|---|
| | 154 | /* TODO: use the destruction callback to track ref leaks */ |
|---|
| | 155 | vlc_threadvar_create( &held_objects, NULL ); |
|---|
| | 156 | #endif |
|---|
| 145 | 157 | } |
|---|
| 146 | 158 | else |
|---|
| … | … | |
| 372 | 384 | /* We are the global object ... no need to lock. */ |
|---|
| 373 | 385 | vlc_mutex_destroy( &structure_lock ); |
|---|
| | 386 | #ifndef NDEBUG |
|---|
| | 387 | vlc_threadvar_delete( &held_objects ); |
|---|
| | 388 | #endif |
|---|
| 374 | 389 | } |
|---|
| 375 | 390 | |
|---|
| … | … | |
| 779 | 794 | internals->i_refcount++; |
|---|
| 780 | 795 | vlc_spin_unlock( &internals->ref_spin ); |
|---|
| | 796 | #ifndef NDEBUG |
|---|
| | 797 | /* Update the list of referenced objects */ |
|---|
| | 798 | /* Using TLS, so no need to lock */ |
|---|
| | 799 | held_list_t *newhead = malloc (sizeof (*newhead)); |
|---|
| | 800 | held_list_t *oldhead = vlc_threadvar_get (&held_objects); |
|---|
| | 801 | newhead->next = oldhead; |
|---|
| | 802 | newhead->obj = p_this; |
|---|
| | 803 | vlc_threadvar_set (&held_objects, newhead); |
|---|
| | 804 | #endif |
|---|
| 781 | 805 | } |
|---|
| 782 | 806 | |
|---|
| … | … | |
| 789 | 813 | vlc_object_internals_t *internals = vlc_internals( p_this ); |
|---|
| 790 | 814 | bool b_should_destroy; |
|---|
| | 815 | |
|---|
| | 816 | #ifndef NDEBUG |
|---|
| | 817 | /* Update the list of referenced objects */ |
|---|
| | 818 | /* Using TLS, so no need to lock */ |
|---|
| | 819 | for (held_list_t *hlcur = vlc_threadvar_get (&held_objects), |
|---|
| | 820 | *hlprev = NULL; |
|---|
| | 821 | hlcur != NULL; |
|---|
| | 822 | hlcur = hlcur->next) |
|---|
| | 823 | { |
|---|
| | 824 | if (hlcur->obj == p_this) |
|---|
| | 825 | { |
|---|
| | 826 | if (hlprev == NULL) |
|---|
| | 827 | vlc_threadvar_set (&held_objects, hlcur->next); |
|---|
| | 828 | else |
|---|
| | 829 | hlprev->next = hlcur->next; |
|---|
| | 830 | free (hlcur); |
|---|
| | 831 | break; |
|---|
| | 832 | } |
|---|
| | 833 | } |
|---|
| | 834 | /* TODO: what if releasing without references? */ |
|---|
| | 835 | #endif |
|---|
| 791 | 836 | |
|---|
| 792 | 837 | vlc_spin_lock( &internals->ref_spin ); |
|---|