lib: return listnode on add for subsequent efficent del

Having to lookup the DLL node to delete it defeats one purpose of using
DLLs.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
This commit is contained in:
Anuradha Karuppiah 2019-03-19 11:39:51 -07:00
parent c6b6b53b29
commit 315999e9b4
2 changed files with 4 additions and 2 deletions

View 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)

View 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.