This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: alloca is bad?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]