1 Star 0 Fork 0

hemars/lab_c

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
list.h 980 Bytes
一键复制 编辑 原始数据 按行查看 历史
hemars 提交于 2024-12-30 22:44 +08:00 . init
#ifndef _LIST_H
#define _LIST_H
#include <stdint.h>
#define offset_of(type, member) ((size_t) & ((type*)0)->member)
#define container_of(ptr, type, member) \
((type*)((char*)(ptr) - offset_of(type, member)))
typedef struct list_structure {
struct list_structure* next;
struct list_structure* prev;
} ListObj;
#define LIST_HEAD_INIT(name) {&(name), &(name)}
#define LIST_HEAD(name) ListObj name = LIST_HEAD_INIT(name)
void list_init(ListObj* list);
void list_insert_head(ListObj* list, ListObj* node);
void list_insert_tail(ListObj* list, ListObj* node);
void list_remove(ListObj* node);
int list_isempty(const ListObj* list);
unsigned int list_len(const ListObj* list);
#define list_entry(node, type, member) container_of(node, type, member)
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hemars/lab_c.git
git@gitee.com:hemars/lab_c.git
hemars
lab_c
lab_c
master

搜索帮助