2016-12-15 Paul Eggert <eggert@cs.ucla.edu>
+ malloca: do not exceed PTRDIFF_MAX
+ * lib/malloca.h: Include xalloc-oversized.
+ (nmalloca): Use xalloc_oversized instead of rolling our own.
+ * modules/malloca (Depends-on):
+ * modules/relocatable-prog-wrapper (Depends-on):
+ Add xalloc-oversized.
+
quotearg: pacify GCC better
* modules/quotearg (Depends-on): Add minmax, stdint.
* lib/quotearg.c: Include minmax.h, stdint.h.
#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
+#include <stdint.h>
+
+#include "xalloc-oversized.h"
#ifdef __cplusplus
It allocates an array of N objects, each with S bytes of memory,
on the stack. S must be positive and N must be nonnegative.
The array must be freed using freea() before the function returns. */
-#if 1
-/* Cf. the definition of xalloc_oversized. */
-# define nmalloca(n, s) \
- ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
- ? NULL \
- : malloca ((n) * (s)))
-#else
-extern void * nmalloca (size_t n, size_t s);
-#endif
+#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
#ifdef __cplusplus