|
Packit Service |
fdd496 |
/* Memory allocation on the stack.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
Copyright (C) 1995, 1999, 2001-2004, 2006-2017 Free Software Foundation,
|
|
Packit Service |
fdd496 |
Inc.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
This program is free software; you can redistribute it and/or modify it
|
|
Packit Service |
fdd496 |
under the terms of the GNU General Public License as published
|
|
Packit Service |
fdd496 |
by the Free Software Foundation; either version 3, or (at your option)
|
|
Packit Service |
fdd496 |
any later version.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
fdd496 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fdd496 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
fdd496 |
General Public License for more details.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
You should have received a copy of the GNU General Public
|
|
Packit Service |
fdd496 |
License along with this program; if not, see
|
|
Packit Service |
fdd496 |
<http://www.gnu.org/licenses/>.
|
|
Packit Service |
fdd496 |
*/
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
|
|
Packit Service |
fdd496 |
means there is a real alloca function. */
|
|
Packit Service |
fdd496 |
#ifndef _GL_ALLOCA_H
|
|
Packit Service |
fdd496 |
#define _GL_ALLOCA_H
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
/* alloca (N) returns a pointer to N bytes of memory
|
|
Packit Service |
fdd496 |
allocated on the stack, which will last until the function returns.
|
|
Packit Service |
fdd496 |
Use of alloca should be avoided:
|
|
Packit Service |
fdd496 |
- inside arguments of function calls - undefined behaviour,
|
|
Packit Service |
fdd496 |
- in inline functions - the allocation may actually last until the
|
|
Packit Service |
fdd496 |
calling function returns,
|
|
Packit Service |
fdd496 |
- for huge N (say, N >= 65536) - you never know how large (or small)
|
|
Packit Service |
fdd496 |
the stack is, and when the stack cannot fulfill the memory allocation
|
|
Packit Service |
fdd496 |
request, the program just crashes.
|
|
Packit Service |
fdd496 |
*/
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
#ifndef alloca
|
|
Packit Service |
fdd496 |
# ifdef __GNUC__
|
|
Packit Service |
fdd496 |
# define alloca __builtin_alloca
|
|
Packit Service |
fdd496 |
# elif defined _AIX
|
|
Packit Service |
fdd496 |
# define alloca __alloca
|
|
Packit Service |
fdd496 |
# elif defined _MSC_VER
|
|
Packit Service |
fdd496 |
# include <malloc.h>
|
|
Packit Service |
fdd496 |
# define alloca _alloca
|
|
Packit Service |
fdd496 |
# elif defined __DECC && defined __VMS
|
|
Packit Service |
fdd496 |
# define alloca __ALLOCA
|
|
Packit Service |
fdd496 |
# elif defined __TANDEM && defined _TNS_E_TARGET
|
|
Packit Service |
fdd496 |
# ifdef __cplusplus
|
|
Packit Service |
fdd496 |
extern "C"
|
|
Packit Service |
fdd496 |
# endif
|
|
Packit Service |
fdd496 |
void *_alloca (unsigned short);
|
|
Packit Service |
fdd496 |
# pragma intrinsic (_alloca)
|
|
Packit Service |
fdd496 |
# define alloca _alloca
|
|
Packit Service |
fdd496 |
# elif defined __MVS__
|
|
Packit Service |
fdd496 |
# include <stdlib.h>
|
|
Packit Service |
fdd496 |
# else
|
|
Packit Service |
fdd496 |
# include <stddef.h>
|
|
Packit Service |
fdd496 |
# ifdef __cplusplus
|
|
Packit Service |
fdd496 |
extern "C"
|
|
Packit Service |
fdd496 |
# endif
|
|
Packit Service |
fdd496 |
void *alloca (size_t);
|
|
Packit Service |
fdd496 |
# endif
|
|
Packit Service |
fdd496 |
#endif
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
#endif /* _GL_ALLOCA_H */
|