Article View: gnu.misc.discuss
Article #75629Re: Why alloca()?
From: Chip Salzenberg
Date: Tue, 22 May 1990 13:23
Date: Tue, 22 May 1990 13:23
28 lines
1848 bytes
1848 bytes
According to kyle@cs.odu.edu: >Certain memory management takss are made much easier by using >alloca(), as opposed to malloc() and free(). True, some things become easier. But ease of use isn't the point. If simplicity of programming is your only goal, then you're using the wrong language. Otherwise, simplicity must be balanced against other criteria, such as portability and speed. >Portability needn't suffer, because portable substitutes for alloca() >exist, and these can be used on machines that don't support it. This analysis is incomplete. So-called "portable" alloca implementations are never faster than malloc(), since they call malloc() to do the actual allocation. So using alloca() is fast with some architecture+compiler combinations, it is actually slow with others. I have used alloca() in code that is intrinsically non-portable, and which is therefore not subject to normal portability concerns. But for all other code, I just use malloc(). It saves everyone a lot of time and trouble. I agree with the original poster. The world would be a Better Place if the GNU subroutines -- regex, glob, readline, etc. -- would avoid the use of alloca(). -- Chip Salzenberg at ComDev/TCT <chip%tct@ateng.com>, <uunet!ateng!tct!chip>
Technical Details
Message-ID:
<26593D50.508E@tct.uucp>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!pdn!tscs!tct!chipReferences:
<1990May19.044239.16031@egsner.cirr.com> <1990May21.133554.12832@talos.pm.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1025b4,57cdf436494e0ba9 X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 1990-05-22 19:56:58 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!pdn!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: gnu.misc.discuss Subject: Re: Why alloca()? Message-ID: <26593D50.508E@tct.uucp> Date: 22 May 90 13:23:27 GMT References: <1990May19.044239.16031@egsner.cirr.com> <1990May21.133554.12832@talos.pm.com> Organization: ComDev/TCT, Sarasota, FL Lines: 28 Posted: Tue May 22 14:23:27 1990