First page Back Continue Last page Overview Graphics
Convenient linked-list facility in <linux/list.h>
- Used in thousands of places in the kernel
Add a struct list_head member to the structure whose instances will be part of the linked list. It is usually named node when each instance needs to only be part of a single list.
Define the list with the LIST_HEAD macro for a global list, or define a struct list_head element and initialize it with INIT_LIST_HEAD for lists embedded in a structure.
Then use the list_*() API to manipulate the list
- Add elements: list_add(), list_add_tail()
- Remove, move or replace elements: list_del(), list_move(), list_move_tail(), list_replace()
- Test the list: list_empty()
- Iterate over the list: list_for_each_*() family of macros