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

_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to