From owner-freebsd-hackers Sun Dec 17 13:31:33 2000 From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 17 13:31:30 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from gw.nectar.com (gw.nectar.com [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id 8978F37B400 for ; Sun, 17 Dec 2000 13:31:30 -0800 (PST) Received: from hamlet.nectar.com (hamlet.nectar.com [10.0.1.102]) by gw.nectar.com (Postfix) with ESMTP id C33DF193E1; Sun, 17 Dec 2000 15:31:29 -0600 (CST) Received: (from nectar@localhost) by hamlet.nectar.com (8.11.1/8.9.3) id eBHLVTL63144; Sun, 17 Dec 2000 15:31:29 -0600 (CST) (envelope-from nectar@spawn.nectar.com) Date: Sun, 17 Dec 2000 15:31:29 -0600 From: "Jacques A. Vidrine" To: Chris Costello Cc: hackers@FreeBSD.ORG Subject: Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c) Message-ID: <20001217153129.B63080@hamlet.nectar.com> References: <200012172110.eBHLAfU46563@freefall.freebsd.org> <20001217151509.A63051@hamlet.nectar.com> <20001217151735.D54486@holly.calldei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20001217151735.D54486@holly.calldei.com>; from chris@calldei.com on Sun, Dec 17, 2000 at 03:17:35PM -0600 X-Url: http://www.nectar.com/ Sender: nectar@nectar.com Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Dec 17, 2000 at 03:17:35PM -0600, Chris Costello wrote: > 2. The C standard dictates that free() does nothing when it > gets a NULL argument. Well, it dictates that free(NULL) is safe -- it doesn't dictate that it ``does nothing''. Which brings me to my next comment: > The other two are just extra clutter. I suspect that the programmer writing if (data) free(data); is motivated by the wish to avoid the function call overhead if you already know darn well that there is nothing to free. In the multithreaded case, there is probably some locking going on, too. I don't blame authors of storage allocation code if they do not write free like this: void free(void *p) { if (p == NULL) return; . . . It would be silly to optimize for freeing NULL pointers. -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message