]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2003-09-24 sowmini.varadhan@sun.com
authorpaul <paul>
Tue, 23 Sep 2003 23:47:14 +0000 (23:47 +0000)
committerpaul <paul>
Tue, 23 Sep 2003 23:47:14 +0000 (23:47 +0000)
* lib/linklist.c: (if_cmp_func) Fix handling of case where
  list->cmp returns 0.

lib/linklist.c

index 3cb10caf1703ab7fa65676c6120df47c07a5e227..049ab0bb497d4a43943eafa3f5b145be2f6df4b8 100644 (file)
@@ -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)