第一次理解通用链表
1 #ifndef _LIST_H 2 #define _LIST_H 3 #include"stdio.h" 4 #define _INLINE_ static inline 5 6 struct list_head { 7 struct list_head *next, *prev; 8 }; 9 10 #define LIST_HEAD_INIT(name) {&(name), &(name)} 11 12 #define LIST_HEAD(name) \ 13 struct list_head name = LIST_HEAD_INIT(name) 14 15 #define INIT_LIST_HEAD(ptr) do {\ 16 (ptr)->next = (ptr); (ptr)->prev = (ptr); \ 17 } while (0) 18 19 _INLINE_ void __list_add(struct list_head *add, 20 struct list_head *prev, 21 struct list_head *next) 22 { 23 next->prev = add; 24 add->next = next; 25 add->prev = prev; 26 prev->next = add; 27 } 28 29 _INLINE