[vlc-devel] [PATCH] variables: simplify the access to/from vlc_object_t and vlc_object_internals_t

Steve Lhomme robux4 at videolabs.io
Wed Jul 26 11:05:08 CEST 2017


Since we assume obj = priv + 1 that means we assume the offset between the 2
structures is always sizeof(vlc_object_internals_t).
---
 src/misc/variables.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/misc/variables.h b/src/misc/variables.h
index bab14c8567..4b925848a1 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -58,9 +58,9 @@ struct vlc_object_internals
     max_align_t aligned_end[];
 };
 
-# define vlc_internals(obj) \
-    container_of(VLC_OBJECT(obj), struct vlc_object_internals, aligned_end)
-# define vlc_externals(priv ) ((vlc_object_t *)((priv)->aligned_end))
+# define vlc_internals(obj)  (((vlc_object_internals_t*) obj) - 1)
+# define vlc_externals(priv) \
+    ((vlc_object_t *)(((vlc_object_internals_t*) priv) + 1))
 
 void DumpVariables(vlc_object_t *obj);
 
-- 
2.12.1



More information about the vlc-devel mailing list