[vlc-commits] Add container_of() convenience wrapper for offsetof()
Rémi Denis-Courmont
git at videolan.org
Wed Jun 7 22:21:15 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 7 23:02:30 2017 +0300| [b7933615fa00bb4c9b48126c6536c2ca6794c286] | committer: Rémi Denis-Courmont
Add container_of() convenience wrapper for offsetof()
(Name comes Linux kernel. Implementation is from scratch.)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b7933615fa00bb4c9b48126c6536c2ca6794c286
---
include/vlc_common.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index a3663accdd..e1cf885379 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -842,6 +842,9 @@ typedef struct {
VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t );
+#define container_of(ptr, type, member) \
+ ((type *)(((char *)(ptr)) - offsetof(type, member)))
+
/* Aligned memory allocator */
#ifdef __MINGW32__
More information about the vlc-commits
mailing list