X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flists.h;h=39036913f8d99a3d8eac7bdb0c1c1cce1ace083a;hb=b4d79987a979bcbf749294c706fdc8c4ae8f9304;hp=48b7de99c0dd01c58d2ef15125c1bd38b8c269a3;hpb=a7ae6132558a824c049ff55abb741c8ed1162aea;p=libucw.git diff --git a/lib/lists.h b/lib/lists.h index 48b7de99..39036913 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -1,11 +1,27 @@ /* - * Sherlock Library -- Linked Lists + * UCW 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 +#ifndef _UCW_LISTS_H +#define _UCW_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; @@ -37,7 +53,7 @@ void add_tail_list(list *, list *); void init_list(list *); void insert_node(node *, node *); -#if !defined(_SHERLOCK_LISTS_C) && defined(__GNUC__) +#if !defined(_UCW_LISTS_C) && defined(__GNUC__) #define LIST_INLINE extern inline #include "lib/lists.c" #undef LIST_INLINE