Попинайте реализацию, пожалуйста.
/**
* Intrusive doubly-linked list.
*
* The list is looped, thus when empty its head node must have both
* 'prev' and 'next' field point the same value pointing to the head.
*/
struct list
{
struct list *prev;
struct list *next;
};
#define make_list_head(head) \
{ \
.prev = &head, .next = &head \
}
/**
* Inserts new element into the list.
* @return new list head.
*/
struct list *list_insert (struct list *, struct list *);
/**
* Remove element from the list.
* @return new list head or NULL.
*/
struct list *list_remove (struct list *);
struct list *
list_insert (struct list *head, struct list *node)
{
node->prev = head;
node->next = head->next;
head->next->prev = node;
return head->next = node;
}
struct list *
list_remove (struct list *node)
{
struct list *prev = node->prev;
struct list *next = node->next;
next->prev = prev;
return prev->next = next;
}