summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorgdt <gdt>2003-12-22 15:56:00 +0000
committergdt <gdt>2003-12-22 15:56:00 +0000
commit297602162c89b10f6ee41c21e6302bcc51199a3d (patch)
tree57bc991e38997884ee3cb8fe4f2e4a0884a9b7b0 /lib
parent1f431d2d989b3a0a43b8ed0c2681619812e4259c (diff)
add comments clarifying the operation of listnode_add_sort
Diffstat (limited to 'lib')
-rw-r--r--lib/linklist.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/linklist.c b/lib/linklist.c
index 6fc03e16..d6eeab41 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -80,7 +80,12 @@ listnode_add (struct list *list, void *val)
list->count++;
}
-/* Add new node with sort function. */
+/*
+ * Add a node to the list. If the list was sorted according to the
+ * cmp function, insert a new node with the given val such that the
+ * list remains sorted. The new node is always inserted; there is no
+ * notion of omitting duplicates.
+ */
void
listnode_add_sort (struct list *list, void *val)
{
@@ -94,6 +99,7 @@ listnode_add_sort (struct list *list, void *val)
{
for (n = list->head; n; n = n->next)
{
+ /* XXX should an "equal" node be inserted before or after? */
if ((*list->cmp) (val, n->data) <= 0)
{
new->next = n;