Created
October 12, 2012 19:23
-
-
Save aji/3880975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct foo { | |
| int data1; | |
| char *data2; | |
| mytype_t mymember; | |
| int data3; | |
| }; | |
| ... | |
| struct foo blah; | |
| mytype_t *var = &(blah.mymember); | |
| container_of(var, struct foo, mymember); /* returns pointer to blah */ | |
| ... | |
| /* more "practical" example of how this is used in the wild. pretend | |
| somefunc returns a mytype_t pointer */ | |
| struct foo *blah = container_of(somefunc(), struct foo, mymember); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment