From e90fbabdc6a8db7a6bbf9fa22b83da1a03023d32 Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 21 Dec 2003 09:51:42 +0000 Subject: lib/if.c part from [quagga-dev 552] and lib/inklist.c part from [quagga-dev 555]. Okayed by Paul. --- lib/if.c | 3 ++- lib/linklist.c | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/if.c b/lib/if.c index db10bc0f..8237b2f2 100644 --- a/lib/if.c +++ b/lib/if.c @@ -120,7 +120,8 @@ if_create (char *name, int namelen) assert (namelen <= (INTERFACE_NAMSIZ + 1)); strncpy (ifp->name, name, namelen); ifp->name[INTERFACE_NAMSIZ] = '\0'; - listnode_add_sort (iflist, ifp); + if (if_lookup_by_name(ifp->name) == NULL) + listnode_add_sort (iflist, ifp); ifp->connected = list_new (); ifp->connected->del = (void (*) (void *)) connected_free; diff --git a/lib/linklist.c b/lib/linklist.c index 049ab0bb..6fc03e16 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -87,17 +87,15 @@ 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) + if ((*list->cmp) (val, n->data) <= 0) { - new = listnode_new (); - new->data = val; new->next = n; new->prev = n->prev; @@ -112,8 +110,6 @@ listnode_add_sort (struct list *list, void *val) } } - new = listnode_new (); - new->data = val; new->prev = list->tail; if (list->tail) -- cgit v1.2.1