Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------------------------------------------------------------------
- #define LinkData(link,T,m) \
- (T *)((char *)(link) - (unsigned int)(&(((T*)0)->m)))
- // ------------------------------------------------------------------------------------------------
- #define ListForEach(it, list, m) \
- for (it = LinkData((list).next, typeof(*it), m); \
- &it->m != &(list); \
- it = LinkData(it->m.next, typeof(*it), m))
- // ------------------------------------------------------------------------------------------------
- #define ListForEachSafe(it, n, list, m) \
- for (it = LinkData((list).next, typeof(*it), m), \
- n = LinkData(it->m.next, typeof(*it), m); \
- &it->m != &(list); \
- it = n, \
- n = LinkData(n->m.next, typeof(*it), m))
Advertisement
Add Comment
Please, Sign In to add comment