Article View: comp.lang.c.moderated
Article #2578Legal alloca?
From: David Thomas Richard Given
Date: Fri, 12 Apr 1996 12:30
Date: Fri, 12 Apr 1996 12:30
28 lines
1719 bytes
1719 bytes
I think I mentioned using alloca() on this newsgroup before, and received
quite a lot of mail telling me that it was nonstandard, nonportable, and
that use of it was generally heinous. :)
The problem is, it's so useful. There's a lot of cases when I write
programs when I allocate a variable-sized buffer at the beginning of a
function. If I use malloc(), I have to remember to free it at the end.
This means that if the function exits prematurely, I have to either put
the code to free the buffer in twice, or else use a goto. And if I
forget, I get a memory leak. alloca() would handily fix this problem.
There are other examples.
My question is, is there a legal alloca() I can use anywhere? Every
system I've met so far has one, but that's no guarantee that other Unix
systems will (my programs are Unix-specific). I've seen a more advanced
alloca.c that is distributed with some programs, particularly some GNU
ones. How about this one?
I'd really like to be able to use this function. Can I?
Thanks.
--
-------------------------------------------------------------------------------
Why do people surf the Information Superhighway? Won't they get run over?
http://www-hons-cs.cs.st-andrews.ac.uk/~dg
Sun-Earther David Daton Given of Lochcarron
Technical Details
Message-ID:
<4klidc$ne8@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: dtrg@st-andrews.ac.uk (David Thomas Richard Given) Newsgroups: comp.lang.c.moderated Subject: Legal alloca? Date: 12 Apr 1996 07:30:36 -0500 Organization: University Of St. Andrews, Fife, UK. Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4klidc$ne8@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com