delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/03/18:45:17.1

From: jstacey AT plato DOT wadham DOT ox DOT ac DOT uk (J-P)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: BREAKing out of a nested loop
Date: 3 Aug 2000 23:41:11 +0100
Organization: Wadham College Oxford
Lines: 21
Message-ID: <8mcse7$3pa$1@plato.wadham.ox.ac.uk>
References: <005a01bffd43$030a3520$0500007b AT brk> <4 DOT 3 DOT 2 DOT 7 DOT 0 DOT 20000803145250 DOT 00aa2310 AT mail DOT subdimension DOT com>
NNTP-Posting-Host: plato.wadham.ox.ac.uk
X-Trace: news.ox.ac.uk 965342471 11438 163.1.164.74 (3 Aug 2000 22:41:11 GMT)
X-Complaints-To: newsmaster AT ox DOT ac DOT uk
NNTP-Posting-Date: 3 Aug 2000 22:41:11 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <4 DOT 3 DOT 2 DOT 7 DOT 0 DOT 20000803145250 DOT 00aa2310 AT mail DOT subdimension DOT com>,
Matt Lewandowsky  <djgpp AT delorie DOT com> wrote:
>One good reason to keep in mind: you may get into the habit of using it. 
>And in C, it's a worse habit than BASIC. Let's say that you have an 
>oft-used loop whose nesting make this one look simple. Let's say you want 
>to break out of it simply. Lets say that you forgot there's a free() five 
>levels out after this point.  You use goto. See a potential problem?

If you're going to worry about that sort of thing, you should maybe quit
using C and go for, say, Perl or something. C assumes in so /many/ places
that you're clueful enough to free() what you malloc(), or check your
malloc()s to make sure they don't point to NULL. C is, all things being
equal, not safe. goto is a tool like anything else in C and whilst it
should only be used with care, so should sprintf().

(The comparison with Perl is only there because someone crashed our server
with a fscked C++ CGI script a week ago... I think he did something
insane with malloc()s, which he shouldn't have been using in C++
anyways.... :-/ )

J-P

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019