forked from Mirror/frr
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:
parent
c6b6b53b29
commit
315999e9b4
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue