链表的C语言实现
来源:互联网 发布:淘宝12月更新公告 编辑:程序博客网 时间:2024/04/27 23:35
[编辑] C宏实例
以下代码摘自Linux内核2.6.21.5源码(部分),展示了链表的另一种实现思路,未采用ANSI C标准,采用GNU C标准,遵从GPL版权许可。
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)
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline void __list_del(struct list_head * prev, struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
static inline void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
entry->next = NULL;
entry->prev = NULL;
}
#define __list_for_each(pos, head) /
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each_entry(pos, head, member) /
for (pos = list_entry((head)->next, typeof(*pos), member); /
prefetch(pos->member.next), &pos->member != (head); /
pos = list_entry(pos->member.next, typeof(*pos), member))
- 【C语言】C语言实现简单的链表
- C语言单向链表的实现
- C语言实现数据结构的链表
- 链表的c语言实现
- 链表的C语言实现
- C语言实现的单向链表
- 链表的C语言实现
- 单向链表的C语言实现
- c语言一个链表的实现
- c语言双向链表的实现
- 双向链表的C语言实现
- 链表的C语言实现(一)
- C语言实现的链表结构
- C语言单向链表的实现
- 【C语言】双向链表的实现
- c 语言:一个链表的实现
- c语言:双向链表的实现
- 循环链表的C语言实现
- (转)鼠标点击链接 弹出div层 没有锁屏没有移动
- java取整和java四舍五入方法
- Delphi数组初始化
- Hibernate乐观锁 悲观锁
- 烧写flash遇到"no cfi table found"错误总结
- 链表的C语言实现
- 基于Nandflash的Bootloader开发简介
- 介绍 JSON
- 【读书笔记】《杰克·韦尔奇如是说》
- WebService使用DataSet -- 用BinaryFormatter 序列化减少流的大小
- apio2009 convention
- 转载百度百科-----匈牙利命名法(他可以帮我们更方便的理解VC,一起让我们的编程命名更规范吧!)
- CSS 在IE8.0和FF中的区别
- Nboot程序详细分析