From caae4d476fc4c811f92686f1079dea8bd138def5 Mon Sep 17 00:00:00 2001 From: Vasant Hegde Date: Tue, 25 Feb 2020 16:43:27 +0530 Subject: list: Add list_add_after() Signed-off-by: Vasant Hegde Signed-off-by: Oliver O'Halloran --- ccan/list/list.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ccan') diff --git a/ccan/list/list.h b/ccan/list/list.h index fdeddeb..1d75dd9 100644 --- a/ccan/list/list.h +++ b/ccan/list/list.h @@ -184,6 +184,25 @@ static inline void list_add_before(struct list_head *h, struct list_node *n, } /** + * list_add_after - add an entry after another entry. + * @h: the list_head to add the node to (we use it for debug purposes, can be NULL) + * @n: the list_node to add to the list. + * @p: the list_node of the other entry + * + * The list_node does not need to be initialized; it will be overwritten. + */ +static inline void list_add_after(struct list_head *h, struct list_node *n, + struct list_node *p) +{ + n->next = p->next; + n->prev = p; + p->next = n; + n->next->prev = n; + if (h) + (void)list_debug(h); +} + +/** * list_add_tail - add an entry at the end of a linked list. * @h: the list_head to add the node to * @n: the list_node to add to the list. -- cgit v1.1