mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
32853: redefine VARARR() to use heap rather than stack allocation
enable old behavior via "configure --with-stack-allocation"
This commit is contained in:
parent
77119afe19
commit
2f0efe9f59
4 changed files with 22 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
||||||
2014-07-24 Barton E. Schaefer <schaefer@zsh.org>
|
2014-07-24 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 32853: configure.ac, Src/mem.c, Src/zsh_system.h: redefine
|
||||||
|
the VARARR() macro to use heap rather than stack allocation;
|
||||||
|
enable old behavior via "configure --with-stack-allocation"
|
||||||
|
|
||||||
* unposted (see 32892): Src/builtins.c: 'fc -I' is an error
|
* unposted (see 32892): Src/builtins.c: 'fc -I' is an error
|
||||||
|
|
||||||
* 32903: Src/Modules/parameter.c: new empty (unset) elements in
|
* 32903: Src/Modules/parameter.c: new empty (unset) elements in
|
||||||
|
|
|
@ -950,7 +950,10 @@ zrealloc(void *ptr, size_t size)
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* If ptr is NULL, then behave like malloc */
|
/* If ptr is NULL, then behave like malloc */
|
||||||
ptr = malloc(size);
|
if (!(ptr = (void *) malloc(size))) {
|
||||||
|
zerr("fatal error: out of memory");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unqueue_signals();
|
unqueue_signals();
|
||||||
|
|
||||||
|
|
|
@ -286,11 +286,15 @@ struct timezone {
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_STACK_ALLOCATION
|
||||||
#ifdef HAVE_VARIABLE_LENGTH_ARRAYS
|
#ifdef HAVE_VARIABLE_LENGTH_ARRAYS
|
||||||
# define VARARR(X,Y,Z) X (Y)[Z]
|
# define VARARR(X,Y,Z) X (Y)[Z]
|
||||||
#else
|
#else
|
||||||
# define VARARR(X,Y,Z) X *(Y) = (X *) alloca(sizeof(X) * (Z))
|
# define VARARR(X,Y,Z) X *(Y) = (X *) alloca(sizeof(X) * (Z))
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
# define VARARR(X,Y,Z) X *(Y) = (X *) zhalloc(sizeof(X) * (Z))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* we should handle unlimited sizes from pathconf(_PC_PATH_MAX) */
|
/* we should handle unlimited sizes from pathconf(_PC_PATH_MAX) */
|
||||||
/* but this is too much trouble */
|
/* but this is too much trouble */
|
||||||
|
|
10
configure.ac
10
configure.ac
|
@ -140,6 +140,16 @@ AC_HELP_STRING([--enable-zsh-hash-debug], [turn on debugging of internal hash ta
|
||||||
AC_DEFINE(ZSH_HASH_DEBUG)
|
AC_DEFINE(ZSH_HASH_DEBUG)
|
||||||
fi])
|
fi])
|
||||||
|
|
||||||
|
dnl Do you want to dynamically allocate memory on the stack where possible?
|
||||||
|
ifdef([stack-allocation],[undefine([stack-allocation])])dnl
|
||||||
|
AH_TEMPLATE([USE_STACK_ALLOCATION],
|
||||||
|
[Define to 1 if you want to allocate stack memory e.g. with `alloca'.])
|
||||||
|
AC_ARG_ENABLE(stack-allocation,
|
||||||
|
AC_HELP_STRING([--enable-stack-allocation], [allocate stack memory e.g. with `alloca']),
|
||||||
|
[if test x$enableval = xyes; then
|
||||||
|
AC_DEFINE(USE_STACK_ALLOCATION)
|
||||||
|
fi])
|
||||||
|
|
||||||
dnl Pathnames for global zsh scripts
|
dnl Pathnames for global zsh scripts
|
||||||
ifdef([etcdir],[undefine([etcdir])])dnl
|
ifdef([etcdir],[undefine([etcdir])])dnl
|
||||||
AC_ARG_ENABLE(etcdir,
|
AC_ARG_ENABLE(etcdir,
|
||||||
|
|
Loading…
Reference in a new issue