alloca

Torbjorn Granlund tege at swox.com
Thu Dec 8 23:59:32 CET 2005


Joe Keane <jgk at jgk.org> writes:

  I think the TMP_ALLOC is more trouble than it's worth.
  
  The alternative is, in every case, have a modest fixed-size local array;
  use that, or `malloc' if needed, later `free' if needed.
  
This seems error prone, and would require massive changed of the
sources.  I have a better idea:

Define TMP_SMALLOC and TMP_BALLOC, the former doing exacly what
TMP_ALLOC does today with --enable-alloca, and TMP_BALLOC using
the stack unconditionally, i.e., doing what TMP_ALLOC does today
with --enable-alloca=malloc-reentrant.

TMP_ALLOC is changed to choose TMP_SALLOC under a threshold and
TMP_BALLOC else.

This requires minimal changes, the only ones required are to
gmp-impl.h, with optional changes at points where it is known the
allocation is large or small.

And you know what?  It is already implemented and will come in
GMP 4.2.  :-)

-- 
Torbjörn


More information about the gmp-discuss mailing list