[vlc-devel] commit: vlc_list_children: list children _safely_ ( Rémi Denis-Courmont )

git version control git at videolan.org
Fri May 16 17:41:20 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Fri May 16 18:23:09 2008 +0300| [73edaec8ab683970e1344eebf930565381d3d99d]

vlc_list_children: list children _safely_

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73edaec8ab683970e1344eebf930565381d3d99d
---

 include/vlc_objects.h |    4 ++++
 src/libvlccore.sym    |    1 +
 src/misc/objects.c    |   20 ++++++++++++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index c211b22..575e0ec 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -111,6 +111,7 @@ VLC_EXPORT( void *, __vlc_object_find_name, ( vlc_object_t *, const char *, int
 VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
 VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
 VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) );
+VLC_EXPORT( vlc_list_t *, __vlc_list_children, ( vlc_object_t * ) );
 VLC_EXPORT( void, vlc_list_release, ( vlc_list_t * ) );
 
 /* __vlc_object_dump */
@@ -145,6 +146,9 @@ VLC_EXPORT( void, __vlc_object_dump, ( vlc_object_t *p_this ) );
 #define vlc_list_find(a,b,c) \
     __vlc_list_find( VLC_OBJECT(a),b,c)
 
+#define vlc_list_children(a) \
+    __vlc_list_children( VLC_OBJECT(a) )
+
 #define vlc_object_dump(a) \
     __vlc_object_dump( VLC_OBJECT(a))
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 99be574..31f2105 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -405,6 +405,7 @@ vlc_getnameinfo
 vlc_iconv
 vlc_iconv_close
 vlc_iconv_open
+__vlc_list_children
 __vlc_list_find
 vlc_list_release
 vlc_lldiv
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 4c6547d..851f1bd 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -1021,6 +1021,26 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
     return p_list;
 }
 
+/**
+ * Gets the list of children of an objects, and increment their reference
+ * count.
+ * @return a list (possibly empty) or NULL in case of error.
+ */
+vlc_list_t *__vlc_list_children( vlc_object_t *obj )
+{
+    vlc_list_t *l;
+
+    vlc_mutex_lock( &structure_lock );
+    l = NewList( obj->i_children );
+    for (int i = 0; i < l->i_count; i++)
+    {
+        vlc_object_yield( obj->pp_children[i] );
+        l->p_values[i].p_object = obj->pp_children[i];
+    }
+    vlc_mutex_unlock( &structure_lock );
+    return l;
+}
+
 /*****************************************************************************
  * DumpCommand: print the current vlc structure
  *****************************************************************************




More information about the vlc-devel mailing list