Skip to content

Commit

Permalink
list: Add list_add_after()
Browse files Browse the repository at this point in the history
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
Vasant Hegde authored and oohal committed Feb 26, 2020
1 parent c8418ac commit caae4d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ccan/list/list.h
Expand Up @@ -183,6 +183,25 @@ static inline void list_add_before(struct list_head *h, struct list_node *n,
(void)list_debug(h);
}

/**
* 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
Expand Down

0 comments on commit caae4d4

Please sign in to comment.