zephyr/include/misc
Benjamin Walsh d032bb88cc 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: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-16 04:56:22 +00:00
..
__assert.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
byteorder.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
dlist.h dlist: add SYS_DLIST_ITERATE_FROM_NODE() 2017-02-16 04:56:22 +00:00
nano_work.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
printk.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
reboot.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
ring_buffer.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
slist.h slist: Introduce CONTAINER macros 2017-02-10 16:16:12 +00:00
stack.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
util.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00