From owner-freebsd-current Tue Jul 2 14:19:31 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B113F37C5C1 for ; Tue, 2 Jul 2002 14:13:11 -0700 (PDT) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id BFBFC44BAE for ; Tue, 2 Jul 2002 13:00:25 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020702200020.GGJY24728.rwcrmhc51.attbi.com@InterJet.elischer.org>; Tue, 2 Jul 2002 20:00:20 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id MAA97931; Tue, 2 Jul 2002 12:58:26 -0700 (PDT) Date: Tue, 2 Jul 2002 12:58:24 -0700 (PDT) From: Julian Elischer To: Jonathan Lemon Cc: current@freebsd.org Subject: Re: additional queue macro In-Reply-To: <20020702095402.D1020@prism.flugsvamp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 2 Jul 2002, Jonathan Lemon wrote: > What do people think about adding the following macro to ? > (I don't care much about the name, just the functionality) > > #define TAILQ_FOREACH_TMP(var, tmp, head, field) \ > for ((var) = TAILQ_FIRST((head)); \ > (var) && (((tmp) = TAILQ_NEXT((var), field)) || 1); \ > (var) = (tmp)) Certainly this is moving in the right direction.. (acknowleging the problem).. It does the job. but if someone knows to use it then they probably also know to use a temp variable themselves. It does work in that there is very little the writer can do to screw this up. The question is simply "is it waranted?" It does add complexity.. I guess it needs to be added to all the other types as well (LIST, STAILQ etc) > > Essentially, this provides a traversal of the tailq that is safe > from element removal, while being simple to drop in to those sections > of the code that need updating, as evidenced in the patch below. > -- > Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message