[vlc-devel] commit: Recurse through the object tree instead of using the objects table ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed May 14 20:16:02 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Wed May 14 21:11:18 2008 +0300| [30066f7bd1ce28d48032737de40d96bdff516bf4]
Recurse through the object tree instead of using the objects table
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30066f7bd1ce28d48032737de40d96bdff516bf4
---
src/misc/objects.c | 49 ++++++++++++++++++++-----------------------------
1 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 914b3d9..63c65ec 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -78,7 +78,7 @@ static void SetAttachment ( vlc_object_t *, bool );
static vlc_list_t * NewList ( int );
static void ListReplace ( vlc_list_t *, vlc_object_t *, int );
-/*static void ListAppend ( vlc_list_t *, vlc_object_t * );*/
+static void ListAppend ( vlc_list_t *, vlc_object_t * );
static int CountChildren ( vlc_object_t *, int );
static void ListChildren ( vlc_list_t *, vlc_object_t *, int );
@@ -959,6 +959,19 @@ void __vlc_object_detach( vlc_object_t *p_this )
vlc_mutex_unlock( &structure_lock );
}
+
+static void vlc_tree_find (vlc_object_t *node, int type, vlc_list_t *list)
+{
+ assert (node);
+ vlc_assert_locked (&structure_lock);
+
+ if (node->i_object_type == type)
+ ListAppend (list, node);
+
+ for (int i = 0; i < node->i_children; i++)
+ vlc_tree_find (node->pp_children[i], type, list);
+}
+
/**
****************************************************************************
* find a list typed objects and increment their refcount
@@ -969,7 +982,6 @@ void __vlc_object_detach( vlc_object_t *p_this )
vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
{
vlc_list_t *p_list;
- vlc_object_t **pp_current, **pp_end;
int i_count = 0, i_index = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global();
@@ -979,31 +991,10 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
switch( i_mode & 0x000f )
{
case FIND_ANYWHERE:
- pp_current = p_libvlc_global->pp_objects;
- pp_end = pp_current + p_libvlc_global->i_objects;
-
- for( ; pp_current < pp_end ; pp_current++ )
- {
- if( vlc_internals(*pp_current)->b_attached
- && (*pp_current)->i_object_type == i_type )
- {
- i_count++;
- }
- }
-
- p_list = NewList( i_count );
- pp_current = p_libvlc_global->pp_objects;
-
- for( ; pp_current < pp_end ; pp_current++ )
- {
- if( vlc_internals(*pp_current)->b_attached
- && (*pp_current)->i_object_type == i_type )
- {
- ListReplace( p_list, *pp_current, i_index );
- if( i_index < i_count ) i_index++;
- }
- }
- break;
+ p_list = NewList (0);
+ if (p_list != NULL)
+ vlc_tree_find (VLC_OBJECT (p_libvlc_global), i_type, p_list);
+ break;
case FIND_CHILD:
i_count = CountChildren( p_this, i_type );
@@ -1570,7 +1561,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
return;
}
-/*static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
+static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
{
if( p_list == NULL )
{
@@ -1591,7 +1582,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
p_list->i_count++;
return;
-}*/
+}
static int CountChildren( vlc_object_t *p_this, int i_type )
{
More information about the vlc-devel
mailing list