From owner-freebsd-hackers Mon Dec 18 13:17:17 2000 From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 18 13:17:13 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from chopper.Poohsticks.ORG (chopper.poohsticks.org [63.227.60.73]) by hub.freebsd.org (Postfix) with ESMTP id 4BC4C37B400 for ; Mon, 18 Dec 2000 13:17:13 -0800 (PST) Received: from chopper.Poohsticks.ORG (drew@localhost.poohsticks.org [127.0.0.1]) by chopper.Poohsticks.ORG (8.10.1/8.10.1) with ESMTP id eBILHCh06143 for ; Mon, 18 Dec 2000 14:17:12 -0700 Message-Id: <200012182117.eBILHCh06143@chopper.Poohsticks.ORG> To: hackers@FreeBSD.ORG Subject: Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c) In-reply-to: Your message of "Mon, 18 Dec 2000 13:11:12 CST." <20001218131112.B65143@hamlet.nectar.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6139.977174232.1@chopper.Poohsticks.ORG> Date: Mon, 18 Dec 2000 14:17:12 -0700 From: Drew Eckhardt Sender: drew@chopper.Poohsticks.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <20001218131112.B65143@hamlet.nectar.com>, n@nectar.com writes: > /* Case 1 */ /* Case 2 */ > if (data) vs. free(data) > free(data); > >I don't see that Case 1 obfuscates anything. In some cases I find it >clearer: Case 1 implies that maybe no memory was allocated. Case 2 >seems to imply that memory was indeed allocated. When functions fit on one screen (where "one screen" is platform dependant, but probably 80 columns wide (you may want hard copy which doesn't wrap) and somewhat less than 60 lines long (given 19" monitors as a defacto standard and the font sizes required to accomodate aging eyes that have stared at computer screens for far too long)), you can see variable definitions and their use at the same time, if and else clauses at the same time, the end of for loops along with what happens to variables just after that, etc. Such functions can be groked in less time than those suffering from sprawl. Anything which stretches functions out like this if (data) { free(data); } rather than this free(data); contributes to sprawl, and in marginal cases may be the proverbial straw which breaks the camel's back. if (data) free (data); doesn't pose that problem, although it is inconsistant with most coding standards. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message