Mail Archives: djgpp/2000/08/03/18:45:17.1
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 -