X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Flists.c;h=043c36495a098980102341764d060c9180a758bd;hb=ed4e86de76d1c3bfb685207fe00078950f67355a;hp=b0d611df497fc8758322960754e40a05bcc948a0;hpb=03846211ba84582b133a985200502a39462dfe66;p=libucw.git diff --git a/lib/lists.c b/lib/lists.c index b0d611df..043c3649 100644 --- a/lib/lists.c +++ b/lib/lists.c @@ -1,36 +1,40 @@ /* - * Sherlock Library -- Linked Lists + * UCW Library -- Linked Lists * - * (c) 1997 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. */ -#include +#include "lib/lib.h" -#include "lists.h" +#define _UCW_LISTS_C +#include "lib/lists.h" -void +LIST_INLINE void add_tail(list *l, node *n) { - node *z = l->tail.prev; + node *z = l->tail; - n->next = &l->tail; + n->next = (node *) &l->null; n->prev = z; z->next = n; - l->tail.prev = n; + l->tail = n; } -void +LIST_INLINE void add_head(list *l, node *n) { - node *z = l->head.next; + node *z = l->head; n->next = z; - n->prev = &l->head; + n->prev = (node *) &l->head; z->prev = n; - l->head.next = n; + l->head = n; } -void +LIST_INLINE void insert_node(node *n, node *after) { node *z = after->next; @@ -41,7 +45,7 @@ insert_node(node *n, node *after) z->prev = n; } -void +LIST_INLINE void rem_node(node *n) { node *z = n->prev; @@ -51,24 +55,23 @@ rem_node(node *n) x->prev = z; } -void +LIST_INLINE void init_list(list *l) { - l->head.next = &l->tail; - l->head.prev = NULL; - l->tail.next = NULL; - l->tail.prev = &l->head; + l->head = (node *) &l->null; + l->null = NULL; + l->tail = (node *) &l->head; } -void +LIST_INLINE void add_tail_list(list *to, list *l) { - node *p = to->tail.prev; - node *q = l->head.next; + node *p = to->tail; + node *q = l->head; p->next = q; q->prev = p; - q = l->tail.prev; - q->next = &to->tail; - to->tail.prev = q; + q = l->tail; + q->next = (node *) &to->null; + to->tail = q; }