Skip to content

Display and control your Android device

Add container_of() macro

Romain Vimont08f1fd46c8f2
diff --git a/app/src/common.h b/app/src/common.h
index 27c8d2fb..accbc615 100644
--- a/app/src/common.h
+++ b/app/src/common.h
@@ -8,4 +8,7 @@
#define MIN(X,Y) (X) < (Y) ? (X) : (Y)
#define MAX(X,Y) (X) > (Y) ? (X) : (Y)
+#define container_of(ptr, type, member) \
+ ((type *) (((char *) (ptr)) - offsetof(type, member)))
+
#endif