笔记:<<the linux kernel primer>>
linux中的链表常见的是循环双向链表。其完整代码存放在同文件include/linux/list.h中
1 include/linux/list.h
2 3struct list_head {
4struct list_head *next,*prev;
5};
6 7#define LIST_HEAD_INIT(name) { &(name),&(name)}
8 9#define LIST_HEAD(name) 10struct list_head name = LIST_HEAD_INIT(name)//根据链表的名字创建表头
1112#define INIT_LIST_HEAD(ptr) do { //将头节点中的prev和next指针都指向头节点本身,完成这两个宏调用后name就指向了一个空链表:(头节点的next
13 (ptr)->next = (ptr);(ptr)->prev = (ptr); //指向该链表的表头元素本身)
14 } while (0)
原文:http://www.cnblogs.com/gaocan/p/5325127.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!