summaryrefslogtreecommitdiff
path: root/lib/xalloc.h
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-10-31 13:42:15 +0000
committerJim Meyering <jim@meyering.net>2003-10-31 13:42:15 +0000
commit1ddab8a09e0532d6a1f382410c4c869ea9f8e521 (patch)
tree288a7df36b0e68366149544bfdb2d8291276ad27 /lib/xalloc.h
parent6a9591f5b8a33fc0d332b812b52357be8a1ed79e (diff)
downloadcoreutils-1ddab8a09e0532d6a1f382410c4c869ea9f8e521.tar.xz
Update from gnulib.
Diffstat (limited to 'lib/xalloc.h')
-rw-r--r--lib/xalloc.h8
1 files changed, 8 insertions, 0 deletions
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))