参考:https://www.linuxidc.com/Linux/2016-08/134481.htm
container_of(ptr, type, member)
参数:
ptr:指针
type:类型
member:成员
看一个例子:
Struct test
{
int i;
int j;
char k;
};
Struct test temp;
现在呢如果我想通过temp.j的地址找到temp的首地址就可以使用container_of(&temp.j,struct test,j);
现在我们知道container_of()的作用就是通过一个结构变量中一个成员的地址找到这个结构体变量的首地址。
通俗地讲:通过孩子,找到父亲(根据结构体成员,获取结构体指针的函数)