Documentation of 'alloca' and 'alloca-opt' modules.
[gnulib.git] / doc / alloca.texi
1 @c Documentation of gnulib module 'alloca'.
2
3 The alloca 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
9 module provides a malloc() based emulation. This emulation will not free a
10 memory block immediately when the calling function returns, but rather will
11 wait until the next alloca() call from a function with the same or a shorter
12 stack length. Thus, in some cases, a few memory blocks will be kept although
13 they are not needed any more.
14
15 The user can #include <alloca.h> and use alloca() on all platforms. Note
16 that the #include <alloca.h> must be the first one after the autoconf-generated
17 config.h. Thanks to AIX for this nice restriction!
18
19 An alternative to this module is the 'alloca-opt' module.