/*
- * lists.c -- Functions to implement a double linked list
- * XBoard $Id: lists.c,v 2.1 2003/10/27 19:21:00 mann Exp $
+ * lists.c -- Functions to implement a double linked list XBoard
*
- * Copyright 1995,2009 Free Software Foundation, Inc.
+ * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *
+ * Enhancements Copyright 2005 Alessandro Scotti
*
* ------------------------------------------------------------------------
*
/* Check, if List l is empty; returns TRUE, if it is, FALSE
* otherwise.
*/
-int ListEmpty(l)
- List *l;
+int
+ListEmpty (List *l)
{
return(l->head == (ListNode *) &l->tail);
}
/* Initialize a list. Must be executed before list is used.
*/
-void ListNew(l)
- List *l;
+void
+ListNew (List *l)
{
l->head = (ListNode *) &l->tail;
l->tail = NULL;
/* Remove node n from the list it is inside.
*/
-void ListRemove(n)
- ListNode *n;
+void
+ListRemove (ListNode *n)
{
if (n->succ != NULL) { /* Be safe */
n->pred->succ = n->succ;
/* Delete node n.
*/
-void ListNodeFree(n)
- ListNode *n;
+void
+ListNodeFree (ListNode *n)
{
if (n) {
ListRemove(n);
/* Create a list node with size s. Returns NULL, if out of memory.
*/
-ListNode *ListNodeCreate(s)
- size_t s;
+ListNode *
+ListNodeCreate (size_t s)
{
ListNode *n;
/* Insert node n into the list of node m after m.
*/
-void ListInsert(m, n)
- ListNode *m, *n;
+void
+ListInsert (ListNode *m, ListNode *n)
{
n->succ = m->succ;
n->pred = m;
/* Add node n to the head of list l.
*/
-void ListAddHead(l, n)
- List *l;
- ListNode *n;
+void
+ListAddHead (List *l, ListNode *n)
{
ListInsert((ListNode *) &l->head, n);
}
/* Add node n to the tail of list l.
*/
-void ListAddTail(l, n)
- List *l;
- ListNode *n;
+void
+ListAddTail (List *l, ListNode *n)
{
ListInsert((ListNode *) l->tailPred, n);
}
/* Return element with number n of list l. (NULL, if n doesn't exist.)
* Counting starts with 0.
*/
-ListNode *ListElem(l, n)
- List *l;
- int n;
+ListNode *
+ListElem (List *l, int n)
{
ListNode *ln;