diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-21 22:11:53 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-21 22:11:53 +0000 |
| commit | 844ec28cee41395cdd1cc0cdf8cf0168f9dc1adf (patch) | |
| tree | f2fe0a9a71bb075a5f6f43cd992b89f46b95574f /lib/linklist.c | |
| parent | d0bfb22c223d645e554290ca82581eb06f94ac3b (diff) | |
| parent | 039dc61292de5f3ed5f46316b1940ab6bb184c3f (diff) | |
Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Conflicts:
lib/.gitignore
lib/command.c
lib/command.h
Diffstat (limited to 'lib/linklist.c')
| -rw-r--r-- | lib/linklist.c | 87 |
1 files changed, 40 insertions, 47 deletions
diff --git a/lib/linklist.c b/lib/linklist.c index 4b16f07dd1..d27a2da848 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -122,7 +122,7 @@ listnode_add_sort (struct list *list, void *val) list->count++; } -void +struct listnode * listnode_add_after (struct list *list, struct listnode *pp, void *val) { struct listnode *nn; @@ -157,6 +157,45 @@ listnode_add_after (struct list *list, struct listnode *pp, void *val) pp->next = nn; } list->count++; + return nn; +} + +struct listnode * +listnode_add_before (struct list *list, struct listnode *pp, void *val) +{ + struct listnode *nn; + + assert (val != NULL); + + nn = listnode_new (); + nn->data = val; + + if (pp == NULL) + { + if (list->tail) + list->tail->next = nn; + else + list->head = nn; + + nn->prev = list->tail; + nn->next = pp; + + list->tail = nn; + } + else + { + if (pp->prev) + pp->prev->next = nn; + else + list->head = nn; + + nn->prev = pp->prev; + nn->next = pp; + + pp->prev = nn; + } + list->count++; + return nn; } /* Move given listnode to tail of the list */ @@ -268,52 +307,6 @@ list_delete_node (struct list *list, struct listnode *node) /* ospf_spf.c */ void -list_add_node_prev (struct list *list, struct listnode *current, void *val) -{ - struct listnode *node; - - assert (val != NULL); - - node = listnode_new (); - node->next = current; - node->data = val; - - if (current->prev == NULL) - list->head = node; - else - current->prev->next = node; - - node->prev = current->prev; - current->prev = node; - - list->count++; -} - -/* ospf_spf.c */ -void -list_add_node_next (struct list *list, struct listnode *current, void *val) -{ - struct listnode *node; - - assert (val != NULL); - - node = listnode_new (); - node->prev = current; - node->data = val; - - if (current->next == NULL) - list->tail = node; - else - current->next->prev = node; - - node->next = current->next; - current->next = node; - - list->count++; -} - -/* ospf_spf.c */ -void list_add_list (struct list *l, struct list *m) { struct listnode *n; |
