summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul>2003-09-23 23:47:14 +0000
committerpaul <paul>2003-09-23 23:47:14 +0000
commit729606fea247f482231d78c5e70ae66db98a2678 (patch)
tree6ce91fe54890d3ae2dd219c2c05f08450c17de60
parent90578521e5f332e65e97f7612485d04ace5c0ba5 (diff)
2003-09-24 sowmini.varadhan@sun.com
* lib/linklist.c: (if_cmp_func) Fix handling of case where list->cmp returns 0.
-rw-r--r--lib/linklist.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/linklist.c b/lib/linklist.c
index 3cb10caf..049ab0bb 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -87,15 +87,17 @@ listnode_add_sort (struct list *list, void *val)
struct listnode *n;
struct listnode *new;
- new = listnode_new ();
- new->data = val;
if (list->cmp)
{
for (n = list->head; n; n = n->next)
{
+ if ((*list->cmp) (val, n->data) == 0)
+ return;
if ((*list->cmp) (val, n->data) < 0)
{
+ new = listnode_new ();
+ new->data = val;
new->next = n;
new->prev = n->prev;
@@ -110,6 +112,8 @@ listnode_add_sort (struct list *list, void *val)
}
}
+ new = listnode_new ();
+ new->data = val;
new->prev = list->tail;
if (list->tail)