🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2610

Re: Legal alloca?

#2610
From: Michael F Gordon
Date: Wed, 17 Apr 1996 15:44
22 lines
1548 bytes
In <4kr7b2$kcb@solutions.solon.com> stanr@tiac.net (Stan Ryckman) writes:
>[replacement example changing alloca() to malloc() and inserting free()
>also snipped]
>Your example is too simple; that's an obvious conversion.
>Much more difficult is where alloca() has been used in a loop, to
>(for example) build a linked list (or worse) on the stack, and
>"return" has been used to free all the spaghetti.

Another place where I've found alloca() very useful is to allocate
memory in a recursive descent parser for a simple calculator.
Instead of cluttering the code with error checks at every step and
having to free memory and pass error values back up the calling
chain, I just longjmp'd back to the top level parse() function
whenever one of the low level routines found an error.

So, just how non-portable and horrible is this?


Michael Gordon
--
Politicians are like nappies, both should be changed regularly
and for the same reason - graffito on a wall in Yeovil.
Technical Details
Message-ID: <4l33l8$7of@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4klidc$ne8@solutions.solon.com> <4koe4u$8sl@solutions.solon.com> <4kr7b2$kcb@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: mfg@ee.edinburgh.ac.uk (Michael F Gordon)
Newsgroups: comp.lang.c.moderated
Subject: Re: Legal alloca?
Date: 17 Apr 1996 10:44:40 -0500
Organization: Edinburgh University
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4l33l8$7of@solutions.solon.com>
References: <4klidc$ne8@solutions.solon.com> <4koe4u$8sl@solutions.solon.com> <4kr7b2$kcb@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-CDA: Exon you, congress cretins
X-Newsreader: NN version 6.5.0 #1 (NOV)