I have met two ways to implement double linked list:
#define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \
}
this way is in the FreeBsd queue.h
,I want to know why it uses a pointer to pointer le_prev
?
struct list_head {
struct list_head *next, *prev;
};
this way is in the linux list.h
, it just uses two simple pointers.
What is the difference? Which is better, just use a simple pointer and a pointer to pointer or two simple pointers?