Should Wine use alloca or not?

Patrik Stridvall ps at
Mon Feb 12 07:47:33 CST 2001

> Jon Griffiths wrote:
> > 
> > I don't know anything about the Win32 print API, but style 
> wise I tend to
> > stay away from alloca(). It screws up exception handling 
> because it messes
> > with the stack, and is machine dependant. Maybe 
> LocalAlloc() would be a
> > better choice?
> > 
> According to the Microsoft web site, LocalAlloc is deprecated in favor
> of HeapAlloc and friends.

Yes, LocalAlloc is for 16 bit source code compabillity and shouldn't be
used by Win32 code.
> Can anyone comment on whether using alloca will mess up Wine?  (Jon's
> comment seems to imply that he avoids alloca on general principles,
> rather than for Wine-specific reasons.) Does Wine use exceptions?

Wine uses exceptions (sort of), but I don't think alloca will interfer.

IIRC the only thing alloca does on x86 is to move the stack pointer to
allocate space.

The general problem with using alloca is that not all platforms 
supports alloca, however I think all reasonable platforms that
has enough power to support Wine is likely to have it so I don't
see any real reason not to use it.

Currently Wine uses it indirectly since the files generated 
by flex/bison uses it.

That said Alexandre has at least once rejected patches from me that
used alloca, so he doesn't seem to like it. I don't remeber him
saying why though.

So perhaps we should debate whether we should use alloca or not.
Alexandre, can you explain why you have rejected patches with alloca?
Have you any better reason that better safe than sorry?
Not that it is a bad reason but still...

More information about the wine-devel mailing list