Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Oct 2017 16:52:18 -0700
From:      Matt Joras <mjoras@FreeBSD.org>
To:        Mark Johnston <markj@FreeBSD.org>
Cc:        "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r324541 - in head: share/man/man9 sys/kern sys/sys
Message-ID:  <7fa71bd4-5222-deb3-63f5-828046a4219c@FreeBSD.org>
In-Reply-To: <20171014180305.GA75158@raichu>
References:  <201710112153.v9BLroeR007323@repo.freebsd.org> <365AD758-5761-4BD4-A80E-8EF2EA84EAAA@gmail.com> <a8093059-86ed-1582-a8fa-3c9c8800e213@FreeBSD.org> <20171014180305.GA75158@raichu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 10/14/2017 11:03, Mark Johnston wrote:
> TAILQ_FOREACH_SAFE just fetches the next element at the beginning of
> each loop iteration rather than at the end, same as the current
> implementation of clear_unrhdr() does. There's no change to the code
> generated by clang when I replace your loop with:
>
> 	TAILQ_FOREACH_SAFE(up, &uh->head, list, uq) {
> 		if (up->ptr != uh) {
> 			Free(up->ptr);
> 		}
> 		Free(up);
> 	}

Ah, that's a fair point... I was assuming Ngie was suggesting doing a
TAILQ_REMOVE during each iteration, since that's probably the typical
reason to do TAILQ_FOREACH_SAFE. That loop looks better. It would
probably be good to change the queue(3) manpage to suggest that for
deletion.

Matt




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7fa71bd4-5222-deb3-63f5-828046a4219c>