🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #652

Re: NeXT-cc bug report

#652
From: Ralf E. Stranzenbach
Date: Sun, 12 Apr 1992 17:11
49 lines
2053 bytes
In article <1992Apr8.183539.1868@talus.com> ajamison@talus.com (Alex  
Senkevitch) writes:
> In article <1992Apr7.084848.29747@reswi.en.open.de>  
ralf@reswi.en.open.de (Ralf  
> E. Stranzenbach) writes:
> > Hi,
> > 
> > the following code fragment did _not_ compile properly:
> > 
> > 	void some_function (char * s)
> > 	{
> > 		char * d;
> > 		d = strcpy (alloca (strlen (s) + 1), s);
> > 		printf ("%s copied as %s\n", s, d);
> > 	}
> > 
> > There are some problems using "alloca" as part of a functions  
> > parameter list.
> 
> try this:
> 
> void some_function(char *s) {
> 	char *d;
> 
> 	strcpy((d=(char*)malloc(strlen(s)+1)),s);
> 	printf("%s copied as %s\n", s, d);
> }

This is definitly not equivalent to that i want. My code fragment is  
part of a somehow larger function that requires many temporary  
strings. Therefore it is usefull, to use "alloca ()" get the memory  
for these strings - it keeps me from shopkeeping allocated strings.  
Your solution would result in a *big* memory leak.

As somehow (tina) stated, "alloca ()" allocates the memory on top of  
the stack and therefore modifies the stack pointer. This is  
definitely right. This is the way "alloca ()" should work. But it is  
a, say, builtin-function of the cc and therefore cc should know about  
the nasty side effects.

	- ralf

--
Ralf E.Stranzenbach  -   (NeXT)-Mail: ralf@reswi.en.open.de
                                Fido: via 2:245/5800.12
                       (Voice)-Phone: +49 2302 / 68403
--
Wenn Debugging der Vorgang ist, Fehler aus einem
Programm auszubauen, dann ist das Programmieren
Technical Details
Message-ID: <1992Apr12.171117.16227@reswi.en.open.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!horga!ruhr.de!reswi!ralf
References: <1992Apr8.183539.1868@talus.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!horga!ruhr.de!reswi!ralf
From: ralf@reswi.en.open.de (Ralf E. Stranzenbach)
Newsgroups: comp.sys.next.programmer
Subject: Re: NeXT-cc bug report
Message-ID: <1992Apr12.171117.16227@reswi.en.open.de>
Date: 12 Apr 92 17:11:17 GMT
References: <1992Apr8.183539.1868@talus.com>
Sender: ralf@reswi.en.open.de
Organization: News on  RESWI from ENtenhausen.OPEN.DE
Lines: 49