view doc/alloca-opt.texi @ 7376:5b76a3b030e7

author Karl Berry <>
date Wed, 27 Sep 2006 07:37:50 +0000
parents adb21c293305
children 6bc27027a2d6
line wrap: on
line source

@c Documentation of gnulib module 'alloca-opt'.

@c Copyright (C) 2004 Free Software Foundation, Inc.

@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.2 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
@c Texts.  A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.

The alloca-opt module provides for a function alloca() which allocates memory
on the stack, where the system allows it. A memory block allocated with alloca()
exists only until the function that calls alloca() returns or exits abruptly.

There are a few systems where this is not possible: HP-UX systems, and some
other platforms when the C++ compiler is used. On these platforms the alloca-opt
module provides no replacement, just a preprocessor macro HAVE_ALLOCA.

The user can #include <alloca.h> on all platforms, and use alloca() on those
platforms where the preprocessor macro HAVE_ALLOCA evaluates to true. If
HAVE_ALLOCA is false, the code should use a heap-based memory allocation
based on malloc() or - in C++ - 'new'. Note that the #include <alloca.h> must be
the first one after the autoconf-generated config.h. Thanks to AIX for this nice