1. linux 内核中循环链表
内核中的循环链表实现:
struct list_head{
struct list_head *next, *prev;
};
平时我们用的循环链表实现:
struct list{
struct list *next, *prev;
int value;
};
两者区别在于,list_head中只有前指针next和后指针prev; list中还有我们关心的数据value;
2. list_for_each
list_for_each 是针对内核中特有的循环链表设计的一个宏,能够遍历这个循环链表的每一个成员;
#define list_for_each(pos, head) for(pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each(pos, head) for(pos = (head)->next; pos != (head); pos = pos->next)