Mirror of git://git.busybox.net/busybox with our patches on top
Source
* list_for_each_safe - iterate over elements in a list, but don't dereference
extern "C" {
/* For Watcom C */
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
struct list_head {
struct list_head *next, *prev;
};
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
_INLINE_ void __list_add(struct list_head * add,
struct list_head * prev,
struct list_head * next)
{
next->prev = add;
add->next = next;
add->prev = prev;
prev->next = add;
}
/**
* list_add - add a new entry
* @add: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
_INLINE_ void list_add(struct list_head *add, struct list_head *head)
{
__list_add(add, head, head->next);