Skip to content
Commit 1d66fab0 authored by Benjamin Walsh's avatar Benjamin Walsh Committed by Anas Nashif
Browse files

dlist: add SYS_DLIST_ITERATE_FROM_NODE()



Like SYS_DLIST_FOR_EACH_NODE(), but __dn contains a node where to fetch
the next node from, NULL to start at the head.

Note that the function does not iterate from @a node, but from
node->next. This allows the following:

sys_dnode_t *funcA(sys_dlist_t *list, sys_dnode_t *node)
{
	SYS_DLIST_ITERATE_FROM_NODE(list, node) {
		if (node == <some condition>) {
			return node;
		}
	}
	return NULL;
}

sys_dlist_t list = &<some list>;
sys_dnode_t *node = NULL;

do {
	node = funcA(list, node)
	if (node == <some other condition>) {
		goto found;
	}
} while(node);

<handle error>

found:
<do stuff with node>

Change-Id: I17a5787594a0ed1a4745bd2e1557dd54895105ca
Signed-off-by: default avatarBenjamin Walsh <walsh.benj@gmail.com>
parent 9fc3173c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment