* lib/linklist.c: (if_cmp_func) Fix handling of case where
	  list->cmp returns 0.
This commit is contained in:
paul 2003-09-23 23:47:14 +00:00
parent 90578521e5
commit 729606fea2

View File

@ -87,15 +87,17 @@ listnode_add_sort (struct list *list, void *val)
struct listnode *n; struct listnode *n;
struct listnode *new; struct listnode *new;
new = listnode_new ();
new->data = val;
if (list->cmp) if (list->cmp)
{ {
for (n = list->head; n; n = n->next) for (n = list->head; n; n = n->next)
{ {
if ((*list->cmp) (val, n->data) == 0)
return;
if ((*list->cmp) (val, n->data) < 0) if ((*list->cmp) (val, n->data) < 0)
{ {
new = listnode_new ();
new->data = val;
new->next = n; new->next = n;
new->prev = n->prev; 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; new->prev = list->tail;
if (list->tail) if (list->tail)