我是靠谱客的博主 繁荣红牛,这篇文章主要介绍内核数据结构:链表,队列,映射二叉树,现在分享给大家,希望可以做个参考。

链表代码在<linux/list.h>中声明,其数据结构很简单:

struct list_head {

            struct list_head *next;

            struct list_head *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;
}
/**
 * container_of - cast a member of a structure out to the containing structure
 * @ptr: the pointer to the member.
 * @type: the type of the container struct this is embedded in.
 * @member: the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({   
 const typeof( ((type *)0)->member ) *__mptr = (ptr); 
 (type *)( (char *)__mptr - offsetof(type,member) );})

最后

以上就是繁荣红牛最近收集整理的关于内核数据结构:链表,队列,映射二叉树的全部内容,更多相关内核数据结构:链表内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部