[vlc-commits] objects: privatize typename

Rémi Denis-Courmont git at videolan.org
Tue Feb 19 17:40:03 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb 19 18:34:34 2019 +0200| [dae9293c8aed0685967880a99b0fb8ecea679402] | committer: Rémi Denis-Courmont

objects: privatize typename

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

 include/vlc_objects.h | 6 ------
 src/misc/objects.c    | 5 +++--
 src/misc/variables.h  | 1 +
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 3fcb1839e9..4fdd2c851a 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -37,12 +37,6 @@
  */
 struct vlc_common_members
 {
-    /** Object type name
-     *
-     * A constant string identifying the type of the object (for logging)
-     */
-    const char *object_type;
-
     /** Log messages header
      *
      * Human-readable header for log messages. This is not thread-safe and
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 9c66745973..c3c29d141b 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -199,6 +199,8 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
     vlc_object_internals_t *priv = malloc (sizeof (*priv) + length);
     if (unlikely(priv == NULL))
         return NULL;
+
+    priv->typename = typename;
     priv->psz_name = NULL;
     priv->var_root = NULL;
     vlc_mutex_init (&priv->var_lock);
@@ -210,7 +212,6 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
     priv->resources = NULL;
 
     vlc_object_t *obj = (vlc_object_t *)(priv + 1);
-    obj->obj.object_type = typename;
     obj->obj.header = NULL;
     obj->obj.force = false;
     memset (obj + 1, 0, length - sizeof (*obj)); /* type-specific stuff */
@@ -280,7 +281,7 @@ void vlc_object_set_destructor( vlc_object_t *p_this,
 
 const char *vlc_object_typename(const vlc_object_t *obj)
 {
-    return obj->obj.object_type;
+    return vlc_internals(obj)->typename;
 }
 
 static vlc_mutex_t name_lock = VLC_STATIC_MUTEX;
diff --git a/src/misc/variables.h b/src/misc/variables.h
index 21e403ea13..3e049480ad 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 */
+    const char *typename; /**< Object type human-readable name */
     char           *psz_name; /* given name */
 
     /* Object variables */



More information about the vlc-commits mailing list