双向内核循环链表:
- 在一个链表结构体里内嵌一个指针域结构体small_list , 其成员有前驱指针和后继指针但指向的不再是大的结构体,而是small_list。
定义结构体:
typedef struct DOU_KEL_NODE_LIST
{
struct list_head small_list;
int data;
}Dou_Kel_Node_List, *PDou_Kel_Node_List;
struct list_head
{
struct list_head *prev;
struct list_head *next;
};
- 重要:如何通过small_list来获取大结构体地址?
p = (PDou_Kel_Node_List)((char*)((head->small_list).next)-(unsiged long)&((PDou_Kel_Node_List)0->small_list))