This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: alloca is bad?
- To: gdb at sources dot redhat dot com
- Subject: Re: alloca is bad?
- From: Nick Duffek <nsd at redhat dot com>
- Date: Fri, 10 Nov 2000 00:03:51 -0500
- References: <20001109222231.A26675@redhat.com>
On 9-Nov-2000, Christopher Faylor wrote:
>I've been told in private email that I mustn't use alloca
Say it ain't so!
>Alloca is useful.
Especially because multi-arching is turning small compile-time constants
into run-time variables all over the place. If we can't use alloca, then
wherever there's something like this:
char rawbuf[MAX_REGISTER_SIZE];
we'll have to convert it to this:
char *rawbuf;
...
rawbuf = malloc (MAX_REGISTER_SIZE);
and do one of two things:
1. Perform the usual painful cleanup-chain surgery.
2. Carefully analyze the function and its entire call subtree to make
sure non-local returns are impossible.
Either way, we're in for a lot more complexity -- and therefore bugs --
than if we use alloca.
Nick