Re: What's wrong with alloca() ?

barmar@think.com (Barry Margolin)
6 Jan 1992 04:40:09 GMT

          From comp.compilers

Related articles
[7 earlier articles]
Re: What's wrong with alloca() ? wicklund@intellistor.com (1991-12-30)
Re: What's wrong with alloca() ? wws@renaissance.cray.com (1991-12-30)
Re: What's wrong with alloca() ? jfc@athena.mit.edu (1991-12-31)
Re: What's wrong with alloca() ? GORMAN_B@prime1.lancashire-poly.ac.uk (Barry Gorman) (1992-01-03)
Re: What's wrong with alloca() ? rankin@eql.caltech.edu (1992-01-05)
Re: What's wrong with alloca() ? pcg@aber.ac.uk (1992-01-05)
Re: What's wrong with alloca() ? barmar@think.com (1992-01-06)
| List of all articles for this month |

Newsgroups: comp.compilers,comp.unix.aix
From: barmar@think.com (Barry Margolin)
Keywords: storage, design
Organization: Thinking Machines Corporation, Cambridge MA, USA
References: 91-12-075 92-01-020
Date: 6 Jan 1992 04:40:09 GMT

In article 92-01-020 pcg@aber.ac.uk (Piercarlo Grandi) writes:
> void withvector(proc,bytes)
> void (*proc)(/* char *, unsigned */);
> unsigned bytes;
> {
> char *vector = malloc(bytes);
> proc(vector,bytes);
> if (vector)
> free(vector);
> }


This implementation doesn't free the vector if proc exits via longjmp().
One of the advantages of stack allocation is that nothing special has to be
done to free the data. There's absolutely no way it can stick around when
you exit the stack frame by any means.
--
Barry Margolin, Thinking Machines Corp.


barmar@think.com
{uunet,harvard}!think!barmar
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.