Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 May 2013 13:57:51 +1000
From:      Lawrence Stewart <lstewart@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Adding a FOREACH_CONTINUE() variant to queue(3)
Message-ID:  <518092BF.9070105@freebsd.org>

next in thread | raw e-mail | index | archive | help
[reposting from freebsd-arch@ - was probably the wrong list]

Hi all,

I've had use for these a few times now when wanting to restart a loop at
a previously found element, and wonder if there are any thoughts about
sticking them (and equivalents for other list types) in <sys/queue.h>?

Cheers,
Lawrence

#define TAILQ_FOREACH_CONTINUE(var, head, field)		\
	for ((var) = ((var) ? (var) : TAILQ_FIRST((head)));	\
	(var);							\
	(var) = TAILQ_NEXT((var), field))


#define SLIST_FOREACH_CONTINUE(var, head, field)		\
	for ((var) = ((var) ? (var) : SLIST_FIRST((head)));	\
	(var);							\
	(var) = SLIST_NEXT((var), field))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?518092BF.9070105>