Skip to content

Instantly share code, notes, and snippets.

@scottt
Created January 20, 2013 14:00
Show Gist options
  • Save scottt/4578849 to your computer and use it in GitHub Desktop.
Save scottt/4578849 to your computer and use it in GitHub Desktop.
struct MyCustomType {
int misc;
struct ExistingType m0;
void *data;
};
void my_callback(struct ExistingType *e)
{
struct MyCustomType *p = containter_of(e, struct MyCustomType, m0);
/* access p->data ... */
}
/* See http://www.kroah.com/log/linux/container_of.html
for how the container_of() macro is implemented. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment