[vlc-devel] [PATCH 3/3] objects: privatize the parent pointer
RĂ©mi Denis-Courmont
remi at remlab.net
Wed Feb 27 18:37:31 CET 2019
---
include/vlc_objects.h | 7 -------
src/misc/objects.c | 8 ++++----
src/misc/variables.h | 1 +
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 582dd7eafa..49833962e8 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -49,13 +49,6 @@ struct vlc_common_members
* See \ref module_need().
*/
bool force;
-
- /** Parent object
- *
- * The parent VLC object in the objects tree. For the root (the LibVLC
- * instance) object, this is NULL.
- */
- vlc_object_t *parent;
};
/**
diff --git a/src/misc/objects.c b/src/misc/objects.c
index fb8c2adec9..192999e257 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -224,7 +224,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
obj->obj.no_interact = parent->obj.no_interact;
/* Attach the child to its parent (no lock needed) */
- obj->obj.parent = vlc_object_hold (parent);
+ priv->parent = vlc_object_hold(parent);
/* Attach the parent to its child (structure lock needed) */
vlc_mutex_lock (&papriv->tree_lock);
@@ -234,7 +234,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
else
{
obj->obj.no_interact = false;
- obj->obj.parent = NULL;
+ priv->parent = NULL;
/* TODO: should be in src/libvlc.c */
int canc = vlc_savecancel ();
@@ -285,7 +285,7 @@ const char *vlc_object_typename(const vlc_object_t *obj)
vlc_object_t *(vlc_object_parent)(vlc_object_t *obj)
{
- return obj->obj.parent;
+ return vlc_internals(obj)->parent;
}
static vlc_mutex_t name_lock = VLC_STATIC_MUTEX;
@@ -333,7 +333,7 @@ static void vlc_object_destroy( vlc_object_t *p_this )
if( p_priv->pf_destructor )
p_priv->pf_destructor( p_this );
- if (unlikely(p_this->obj.parent == NULL))
+ if (unlikely(p_priv->parent == NULL))
{
/* TODO: should be in src/libvlc.c */
var_DelCallback (p_this, "vars", VarsCommand, NULL);
diff --git a/src/misc/variables.h b/src/misc/variables.h
index 3e049480ad..b514c0807f 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -37,6 +37,7 @@ typedef struct vlc_object_internals vlc_object_internals_t;
struct vlc_object_internals
{
alignas (max_align_t) /* ensure vlc_externals() is maximally aligned */
+ vlc_object_t *parent; /**< Parent object (or NULL) */
const char *typename; /**< Object type human-readable name */
char *psz_name; /* given name */
--
2.20.1
More information about the vlc-devel
mailing list