Update from gnulib.
authorJim Meyering <jim@meyering.net>
Fri, 31 Oct 2003 13:42:15 +0000 (13:42 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 31 Oct 2003 13:42:15 +0000 (13:42 +0000)
lib/xalloc.h

index 03c4306..72400e0 100644 (file)
@@ -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))