summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-07-12 16:47:37 +0000
committerJim Meyering <jim@meyering.net>2005-07-12 16:47:37 +0000
commit40db6abec10689d2824e5ac627f94aab924b8b8a (patch)
tree1b3403f7ff26eb193c4decf686a22786901ff8e6
parent95550da8d38f4a5180de366881690ddf2f07ddcb (diff)
downloadcoreutils-40db6abec10689d2824e5ac627f94aab924b8b8a.tar.xz
(X2NREALLOC): Define.
-rw-r--r--lib/xalloc.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/xalloc.h b/lib/xalloc.h
index 24b2d5804..b743d6843 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -61,6 +61,13 @@ char *xstrdup (char const *str);
# define VERIFY_EXPR(assertion) \
(void)((struct {char a[(assertion) ? 1 : -1]; } *) 0)
+/* This is simply a shorthand for the common case in which
+ the third argument to x2nrealloc would be `sizeof (*P)'.
+ Ensure that sizeof (*P) is *not* 1. In that case, it'd be
+ better to use X2REALLOC, although not strictly necessary. */
+# define X2NREALLOC(P, PN) (VERIFY_EXPR (sizeof(*P) != 1), \
+ x2nrealloc (P, PN, sizeof (*P)))
+
/* Using x2realloc (when appropriate) usually makes your code more
readable than using x2nrealloc, but it also makes it so your
code will malfunction if sizeof (*P) ever becomes 2 or greater.