]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: return listnode on add for subsequent efficent del
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Tue, 19 Mar 2019 18:39:51 +0000 (11:39 -0700)
committerAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Sat, 20 Apr 2019 15:33:20 +0000 (08:33 -0700)
Having to lookup the DLL node to delete it defeats one purpose of using
DLLs.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
lib/linklist.c
lib/linklist.h

index f0d0c292450c5dadf8d2586c0d42613a7d854546..d3ecc00306b555549a93f934a2365b1500b65cd2 100644 (file)
@@ -50,7 +50,7 @@ static void listnode_free(struct listnode *node)
        XFREE(MTYPE_LINK_NODE, node);
 }
 
-void listnode_add(struct list *list, void *val)
+struct listnode *listnode_add(struct list *list, void *val)
 {
        struct listnode *node;
 
@@ -68,6 +68,8 @@ void listnode_add(struct list *list, void *val)
        list->tail = node;
 
        list->count++;
+
+       return node;
 }
 
 void listnode_add_head(struct list *list, void *val)
index e75d86343100567b93d045a7d62956fed55ee16e..dd90608bcb5d87852a8daecb7719c93b6e2a287e 100644 (file)
@@ -84,7 +84,7 @@ extern struct list *list_new(void);
  * data
  *    element to add
  */
-extern void listnode_add(struct list *list, void *data);
+extern struct listnode *listnode_add(struct list *list, void *data);
 
 /*
  * Add a new element to the beginning of a list.