aboutsummaryrefslogtreecommitdiff
path: root/src/backend/lib
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-10-18 16:47:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-10-18 16:47:07 -0400
commit8f8d74647880ef53fc674498827b8b8e6c80d125 (patch)
tree412145d663d07975581de1c413730056167c5a91 /src/backend/lib
parent2f2be7473ba28d1e5c96a0a52b30c831d1c0d203 (diff)
downloadpostgresql-8f8d74647880ef53fc674498827b8b8e6c80d125.tar.gz
postgresql-8f8d74647880ef53fc674498827b8b8e6c80d125.zip
Code review for inline-list patch.
Make foreach macros less syntactically dangerous, and fix some typos in evidently-never-tested ones. Add missing slist_next_node and slist_head_node functions. Fix broken dlist_check code. Assorted comment improvements.
Diffstat (limited to 'src/backend/lib')
-rw-r--r--src/backend/lib/ilist.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/backend/lib/ilist.c b/src/backend/lib/ilist.c
index c5831acd67d..0126320d426 100644
--- a/src/backend/lib/ilist.c
+++ b/src/backend/lib/ilist.c
@@ -24,9 +24,11 @@
#include "lib/ilist.h"
/*
- * removes a node from a list
+ * Delete 'node' from list.
*
- * Attention: O(n)
+ * It is not allowed to delete a 'node' which is is not in the list 'head'
+ *
+ * Caution: this is O(n)
*/
void
slist_delete(slist_head *head, slist_node *node)
@@ -47,9 +49,9 @@ slist_delete(slist_head *head, slist_node *node)
}
last = cur;
}
+ Assert(found);
slist_check(head);
- Assert(found);
}
#ifdef ILIST_DEBUG
@@ -61,8 +63,11 @@ dlist_check(dlist_head *head)
{
dlist_node *cur;
- if (head == NULL || !(&head->head))
- elog(ERROR, "doubly linked list head is not properly initialized");
+ if (head == NULL)
+ elog(ERROR, "doubly linked list head address is NULL");
+
+ if (head->head.next == NULL && head->head.prev == NULL)
+ return; /* OK, initialized as zeroes */
/* iterate in forward direction */
for (cur = head->head.next; cur != &head->head; cur = cur->next)
@@ -96,10 +101,10 @@ slist_check(slist_head *head)
slist_node *cur;
if (head == NULL)
- elog(ERROR, "singly linked is NULL");
+ elog(ERROR, "singly linked list head address is NULL");
/*
- * there isn't much we can test in a singly linked list other that it
+ * there isn't much we can test in a singly linked list except that it
* actually ends sometime, i.e. hasn't introduced a cycle or similar
*/
for (cur = head->head.next; cur != NULL; cur = cur->next)