From owner-freebsd-hackers Sun Dec 17 13:25:11 2000 From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 17 13:25:09 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from field.videotron.net (field.videotron.net [205.151.222.108]) by hub.freebsd.org (Postfix) with ESMTP id 491F937B402 for ; Sun, 17 Dec 2000 13:25:09 -0800 (PST) Received: from modemcable213.3-201-24.mtl.mc.videotron.ca ([24.201.3.213]) by field.videotron.net (Sun Internet Mail Server sims.3.5.1999.12.14.10.29.p8) with ESMTP id <0G5Q00BOHE5VJG@field.videotron.net> for hackers@FreeBSD.ORG; Sun, 17 Dec 2000 16:25:07 -0500 (EST) Date: Sun, 17 Dec 2000 16:25:55 -0500 (EST) From: Bosko Milekic Subject: Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c) In-reply-to: <20001217151735.D54486@holly.calldei.com> To: Chris Costello Cc: "Jacques A. Vidrine" , hackers@FreeBSD.ORG Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 17 Dec 2000, Chris Costello wrote: > On Sunday, December 17, 2000, Jacques A. Vidrine wrote: > > What do folks think about > > > > 1) if (data) > > free(data); > > > > versus > > > > 2) free(data); > > > > versus > > > > 3) #define xfree(x) if ((x) != NULL) free(x); > > xfree(data); > > 2. The C standard dictates that free() does nothing when it > gets a NULL argument. The other two are just extra clutter. Agreed. However, in the kernel, all free()s should be made as in (1), in my opinion. (2) is dangerous, and (3) would just obfuscate the code. (I know this does not apply to the commit, but should be noted) > -- > +-------------------+-------------------------------------------------+ > | Chris Costello | This system will self-destruct in five minutes. | > | chris@calldei.com | | > +-------------------+-------------------------------------------------+ Later, Bosko Milekic bmilekic@technokratis.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message