X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Flists.h;h=68c7497f1cde8dcae6415050f839c8df406d84ca;hb=9f87c6fe6552ce8b2236a07307d2f825b0e4c439;hp=ce03656b10bc7eedc00d9ef5586ad9b0b1a0e34d;hpb=5b53087fa5a07ff89d34cf3bf3bc1b28809f05c2;p=libucw.git diff --git a/lib/lists.h b/lib/lists.h index ce03656b..68c7497f 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -1,12 +1,28 @@ /* * Sherlock Library -- Linked Lists * - * (c) 1997--1999 Martin Mares + * (c) 1997--1999 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #ifndef _SHERLOCK_LISTS_H #define _SHERLOCK_LISTS_H +/* + * I admit the list structure is very tricky and also somewhat awkward, + * but it's both efficient and easy to manipulate once one understands the + * basic trick: The list head always contains two synthetic nodes which are + * always present in the list: the head and the tail. But as the `next' + * entry of the tail and the `prev' entry of the head are both NULL, the + * nodes can overlap each other: + * + * head head_node.next + * null head_node.prev tail_node.next + * tail tail_node.prev + */ + typedef struct node { struct node *next, *prev; } node; @@ -38,7 +54,7 @@ void init_list(list *); void insert_node(node *, node *); #if !defined(_SHERLOCK_LISTS_C) && defined(__GNUC__) -#define LIST_INLINE static inline +#define LIST_INLINE extern inline #include "lib/lists.c" #undef LIST_INLINE #else