From 604f2f86cff27b2368239f42a119bda6f244b9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 7 Nov 2009 19:25:34 +0100 Subject: clean --- container_of.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/container_of.c b/container_of.c index 2c0be09..f67b644 100644 --- a/container_of.c +++ b/container_of.c @@ -34,23 +34,23 @@ (type *)( (char *)__mptr - offsetof(type,member) );}) struct node { - int data; - int daat2; - int daat3; - int daat4; - int daaat4; + int data1; + int data2; + int data3; + int data4; + int data5; }; -#define OFFSET offsetof(struct node,daat3) + #define my_offset(ptr, type, member) ( { (type*)(((char*)ptr)-offsetof(type,member)); } ) struct node n; struct node* use_container_of() { - return container_of( &n.daat3, struct node, daat3); + return container_of( &n.data3, struct node, data3); } struct node* use_mine() { - return my_offset( &n.daat3, struct node, daat3); + return my_offset( &n.data3, struct node, data3); /* return (struct node*)(((char*)&n.daat3)-OFFSET); */ } -- cgit v1.1-2-g2b99