summaryrefslogtreecommitdiff
path: root/lib/malloca.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/malloca.h')
-rw-r--r--lib/malloca.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/malloca.h b/lib/malloca.h
index a33907a..8e47c16 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or
@@ -65,8 +65,10 @@ extern "C" {
the function returns. Upon failure, it returns NULL. */
#if HAVE_ALLOCA
# define malloca(N) \
- ((N) < 4032 - sa_increment \
- ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
+ ((N) < 4032 - (2 * sa_alignment_max - 1) \
+ ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
+ + (2 * sa_alignment_max - 1)) \
+ & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
: mmalloca (N))
#else
# define malloca(N) \
@@ -128,10 +130,7 @@ enum
| (sa_alignment_longlong - 1)
#endif
| (sa_alignment_longdouble - 1)
- ) + 1,
-/* The increment that guarantees room for a magic word must be >= sizeof (int)
- and a multiple of sa_alignment_max. */
- sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
+ ) + 1
};
#endif /* _MALLOCA_H */