Article View: comp.std.c
Article #3402Re: GOTO single exit point (was: Re: How to eliminate GOTO?)
From: Malcolm Adamson
Date: Wed, 06 Sep 1995 08:50
Date: Wed, 06 Sep 1995 08:50
35 lines
1826 bytes
1826 bytes
>==========Dann Corbit, 05/09/95========== > >In article <small-0109951141310001@155.34.60.159>, small@ll.mit.edu >says... >> I prefer multiple return statements to multiple goto statements. . >I have a dreaded fear of multiple return statements. >I have seen an enourmous number of memory leaks caused by having an exit >w/o cleanup. On the other hand, if there is only one return, it is not always obvious what clean up is required at that point. Was memory allocated or not? Was a file opened or not? Did the control flow come straight to the return because an entry parameter was invalid? etc. etc. The sort of fault which leads to an early return often needs its own special cleanup. I've also seen errors caused by inserting code at the wrong level of a multiply- nested set of if statements, especially when all the closing } appear close together at the end of a function. ------------------------------------------------------------------------------- ------------------------------- Opinions? What opinions? Malcolm Adamson malcolm.adamson@Dundee.attgis.com AT&T GIS Ltd Tel 01382 592271 Kingsway West Dundee Scotland DD2 3XX
Technical Details
Message-ID:
<DEH785.E85@ddvictor.dundee.ATTGIS.COM>Path:
arc1-ca.pugleaf.net!ddvictor.dundee.ATTGIS.COM!newsReferences:
<42i6l7$jdk@news2100.microsoft.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c Path: arc1-ca.pugleaf.net!ddvictor.dundee.ATTGIS.COM!news From: Malcolm Adamson <malcolm.adamson@Dundee.ATTGIS.COM> Subject: Re: GOTO single exit point (was: Re: How to eliminate GOTO?) X-Nntp-Posting-Host: 153.73.14.137 Message-ID: <DEH785.E85@ddvictor.dundee.ATTGIS.COM> Sender: news@ddvictor.dundee.ATTGIS.COM (Ref news) Reply-To: malcolm.adamson@Dundee.ATTGIS.COM (MALCOLMADAMSON ) Organization: AT&T GIS, Dundee X-Newsreader: DiscussIT 2.0.1.3 for MS Windows [AT&T Software Products Division] References: <42i6l7$jdk@news2100.microsoft.com> Date: Wed, 6 Sep 1995 08:50:29 GMT