[vlc-commits] objects: introduce vlc_object_parent()

Rémi Denis-Courmont git at videolan.org
Thu Feb 28 20:23:29 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Feb 27 19:06:49 2019 +0200| [aee7a197c4f304e1d5986d901defa177e8c65817] | committer: Rémi Denis-Courmont

objects: introduce vlc_object_parent()

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

 include/vlc_objects.h | 10 ++++++++++
 src/libvlccore.sym    |  1 +
 src/misc/objects.c    |  5 +++++
 3 files changed, 16 insertions(+)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 4d59fcfd0b..11b18243e0 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -109,6 +109,16 @@ VLC_API size_t vlc_list_children(vlc_object_t *, vlc_object_t **, size_t) VLC_US
  */
 VLC_API const char *vlc_object_typename(const vlc_object_t *obj) VLC_USED;
 
+/**
+ * Gets the parent of an object.
+ *
+ * \return the parent object (NULL if none)
+ *
+ * \note The returned parent object pointer is valid as long as the child is.
+ */
+VLC_API vlc_object_t *vlc_object_parent(vlc_object_t *obj) VLC_USED;
+#define vlc_object_parent(o) vlc_object_parent(VLC_OBJECT(o))
+
 VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED;
 
 #define vlc_object_create(a,b) vlc_object_create( VLC_OBJECT(a), b )
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a861c988e5..ef9e2d5561 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -675,6 +675,7 @@ vlc_object_find_name
 vlc_object_hold
 vlc_object_release
 vlc_object_typename
+vlc_object_parent
 vlc_object_get_name
 vlc_once
 vlc_rand_bytes
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 07cd418231..c92d74b88a 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -282,6 +282,11 @@ const char *vlc_object_typename(const vlc_object_t *obj)
     return vlc_internals(obj)->typename;
 }
 
+vlc_object_t *(vlc_object_parent)(vlc_object_t *obj)
+{
+    return obj->obj.parent;
+}
+
 static vlc_mutex_t name_lock = VLC_STATIC_MUTEX;
 
 #undef vlc_object_set_name



More information about the vlc-commits mailing list