首先先看内核链表的定义:linux-/include/linux/list.h
struct list_head {
struct list_head *next, *prev;
};
看出来内核链表(循环表)只有前驱和后继指针,没有数据域,这是和一般的单双链表的区别
示意图:
初始化链表:
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
LIST_HEAD(name)相当于struct list_head name = LIST_HEAD_INIT(name)={ &(name), &(name) } 定义并初始化了前驱和后继指针。等于下边
struct list_head {
struct list_head *next, *prev;
}head={&(head),&(head)} 就是一般的结构体定义并初始化。
添加节点:
<