Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!daemon From: scs@adam.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: scope of malloc Summary: don't use alloca Message-ID: <1990Nov7.234315.15508@athena.mit.edu> Date: 7 Nov 90 23:43:15 GMT References: <1791@sirius.ucs.adelaide.edu.au> <1990Nov07.134942.7355@virtech.uucp> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: scs@adam.mit.edu (Steve Summit) Organization: Thermal Technologies, Inc. Lines: 20 In article <1990Nov07.134942.7355@virtech.uucp> cpcahil@virtech.UUCP (Conor P. Cahill) writes: >If you just want the pointer to be around during the function, you can >use alloca() which allocates the data on your stack. Correction: "If you just want the pointer to be around during the function and you want the program to be unportable...", as Doug has just reminded us. >This function is >usually hidden in the libPWB.a library. ...except under BSD, where it's right there in libc.a, and under many other systems, where it doesn't exist at all. The FAQ contains a bit more information on alloca. The summary, which bears repeating, stands: "alloca cannot be used in programs which must be widely portable, no matter how useful it might be." Steve Summit scs@adam.mit.edu