alloca() portability

Oliver Laumann net at opal.cs.tu-berlin.de
Sun Nov 11 03:31:31 AEST 1990


In article <1990Nov09.233527.7489 at chinet.chi.il.us> les at chinet.chi.il.us (Leslie Mikesell) writes:
> The usual "simple" way goes something like this:
> 
> #define BIG_BUFF 1024  /* that should be big enough */
> 
> work(str)
> char *str;
> {
>    buffer[BIG_BUFF);
>    strcpy(buffer,str); /*  make a local copy to manipulate */


This, of course, doesn't work when the amount of data to be stored
in the local buffer can't be determined at compile time.  If it were
known at compile time, there would be no need to use alloca() in the
first place.

--
Oliver Laumann     net at TUB.BITNET     net at tub.cs.tu-berlin.de     net at tub.UUCP



More information about the Comp.lang.c mailing list