gnustandards sync
[gnulib.git] / doc / alloca-opt.texi
1 @c Documentation of gnulib module 'alloca-opt'.
2
3 The alloca-opt module provides for a function alloca() which allocates memory
4 on the stack, where the system allows it. A memory block allocated with alloca()
5 exists only until the function that calls alloca() returns or exits abruptly.
6
7 There are a few systems where this is not possible: HP-UX systems, and some
8 other platforms when the C++ compiler is used. On these platforms the alloca-opt
9 module provides no replacement, just a preprocessor macro HAVE_ALLOCA.
10
11 The user can #include <alloca.h> on all platforms, and use alloca() on those
12 platforms where the preprocessor macro HAVE_ALLOCA evaluates to true. If
13 HAVE_ALLOCA is false, the code should use a heap-based memory allocation
14 based on malloc() or - in C++ - 'new'. Note that the #include <alloca.h> must be
15 the first one after the autoconf-generated config.h. Thanks to AIX for this nice
16 restriction!