From 1ddab8a09e0532d6a1f382410c4c869ea9f8e521 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 31 Oct 2003 13:42:15 +0000 Subject: Update from gnulib. --- lib/xalloc.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/xalloc.h') diff --git a/lib/xalloc.h b/lib/xalloc.h index 03c430699..72400e04a 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -54,9 +54,17 @@ void *xzalloc (size_t s); void *xcalloc (size_t n, size_t s); void *xrealloc (void *p, size_t s); void *xnrealloc (void *p, size_t n, size_t s); +void *x2realloc (void *p, size_t *pn); +void *x2nrealloc (void *p, size_t *pn, size_t s); void *xclone (void const *p, size_t s); char *xstrdup (const char *str); +/* Return 1 if an array of N objects, each of size S, cannot exist due + to size arithmetic overflow. S must be positive and N must be + nonnegative. This is a macro, not an inline function, so that it + works correctly even when SIZE_MAX < N. */ +# define xalloc_oversized(n, s) ((size_t) -1 / (s) < (n)) + /* These macros are deprecated; they will go away soon, and are retained temporarily only to ease conversion to the functions described above. */ # define CCLONE(p, n) xclone (p, (n) * sizeof *(p)) -- cgit v1.2.3-54-g00ecf