#include <list.h>
Data Fields | |
struct os_list_node | head |
Structures to be stored in a list should contains a struct os_list_node as the first field.
struct foo { struct os_list_node node; int bar; ... };
struct os_list_node *node; struct foo *foo; [...] node = &foo->node; foo = (struct foo *)node
A list can be interated from the head to the tail using:
struct os_list_node *node; for (node = os_list_head(list); node != os_list_end(list); node = node->next) { struct foo *foo = (struct foo *)node; ... }
In the above loop, the current list node cannot be removed (with os_list_del()). If this is required use this form of loop:
struct os_list_node *node, *next; for (node = os_list_head(list), next = node->next; node != os_list_end(list); node = next, next = node->next) { struct foo *foo = (struct foo *)node; ... os_list_del(node); ... }