2424#include "lib/ilist.h"
2525
2626/*
27- *removes a node froma list
27+ *Delete ' node' from list.
2828 *
29- * Attention: O(n)
29+ * It is not allowed to delete a 'node' which is is not in the list 'head'
30+ *
31+ * Caution: this is O(n)
3032 */
3133void
3234slist_delete (slist_head * head ,slist_node * node )
@@ -47,9 +49,9 @@ slist_delete(slist_head *head, slist_node *node)
4749}
4850last = cur ;
4951}
52+ Assert (found );
5053
5154slist_check (head );
52- Assert (found );
5355}
5456
5557#ifdef ILIST_DEBUG
@@ -61,8 +63,11 @@ dlist_check(dlist_head *head)
6163{
6264dlist_node * cur ;
6365
64- if (head == NULL || !(& head -> head ))
65- elog (ERROR ,"doubly linked list head is not properly initialized" );
66+ if (head == NULL )
67+ elog (ERROR ,"doubly linked list head address is NULL" );
68+
69+ if (head -> head .next == NULL && head -> head .prev == NULL )
70+ return ;/* OK, initialized as zeroes */
6671
6772/* iterate in forward direction */
6873for (cur = head -> head .next ;cur != & head -> head ;cur = cur -> next )
@@ -96,10 +101,10 @@ slist_check(slist_head *head)
96101slist_node * cur ;
97102
98103if (head == NULL )
99- elog (ERROR ,"singly linked is NULL" );
104+ elog (ERROR ,"singly linkedlist head address is NULL" );
100105
101106/*
102- * there isn't much we can test in a singly linked listother that it
107+ * there isn't much we can test in a singly linked listexcept that it
103108 * actually ends sometime, i.e. hasn't introduced a cycle or similar
104109 */
105110for (cur = head -> head .next ;cur != NULL ;cur = cur -> next )