Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.wizards Subject: Re: evilness of alloca! Message-ID: <10128@smoke.BRL.MIL> Date: 26 Apr 89 08:39:33 GMT References: <19305@adm.BRL.MIL> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <19305@adm.BRL.MIL> rbj@dsys.icst.nbs.gov (Root Boy Jim) writes: >? From: Doug Gwyn >? We just went over that. alloca() is not available on some systems for >? good and sufficient reasons. I would think that any sane programmer >? would avoid it like the plague. >So they get your version. No, my alloca() emulation doesn't work at all for some C implementations and it can be outwitted even on a "nice" architecture. It's strictly for emergency use if you don't have alloca() and run into code that relies on it, until you can get around to fixing the code. >Likewise, bending over backwards to force a problem into the malloc/free >paradigm when it is expressed more naturally in terms of alloca is merely >being pedantic. Avoidance of alloca() is NOT a matter of style (what you call a "religious issue"); it's a matter of practicality. malloc()/free() (also calloc() and realloc()) is the only portable method for dynamic storage allocation in C. If you want your code to be maximally portable, which I hope is normally the case, you must not rely on alloca().