Analogous to offsetof but returns structure offset after the specified
field. Useful for checking whether specific field is present in obtained
data or specify amount of data to copy based on the (last) field needed.

* defs.h: Add offsetofend macro.
---
 defs.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/defs.h b/defs.h
index 2b4118b..758fd8b 100644
--- a/defs.h
+++ b/defs.h
@@ -68,6 +68,11 @@ const char *strerror(int);
 extern char *stpcpy(char *dst, const char *src);
 #endif
 
+#ifndef offsetofend
+# define offsetofend(type, member) \
+       (offsetof(type, member) + sizeof(((type *)NULL)->member))
+#endif
+
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 /* macros */
-- 
1.7.10.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to