00001 /* Memory allocation on the stack. 00002 00003 Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004 Free Software 00004 Foundation, Inc. 00005 00006 This program is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Lesser General Public License as published 00008 by the Free Software Foundation; either version 2.1, or (at your option) 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. */ 00020 00021 /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H 00022 means there is a real alloca function. */ 00023 #ifndef _GNULIB_ALLOCA_H 00024 # define _GNULIB_ALLOCA_H 00025 00026 /* alloca (N) returns a pointer to N bytes of memory 00027 allocated on the stack, which will last until the function returns. 00028 Use of alloca should be avoided: 00029 - inside arguments of function calls - undefined behaviour, 00030 - in inline functions - the allocation may actually last until the 00031 calling function returns, 00032 - for huge N (say, N >= 65536) - you never know how large (or small) 00033 the stack is, and when the stack cannot fulfill the memory allocation 00034 request, the program just crashes. 00035 */ 00036 00037 #ifdef __GNUC__ 00038 # define alloca __builtin_alloca 00039 #elif defined _AIX 00040 # define alloca __alloca 00041 #elif defined _MSC_VER 00042 # include <malloc.h> 00043 # define alloca _alloca 00044 #else 00045 # include <stddef.h> 00046 # ifdef __cplusplus 00047 extern "C" 00048 # endif 00049 void *alloca (size_t); 00050 #endif 00051 00052 #endif /* _GNULIB_ALLOCA_H */