]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(X2NREALLOC): Define.
authorJim Meyering <jim@meyering.net>
Tue, 12 Jul 2005 16:47:37 +0000 (16:47 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 12 Jul 2005 16:47:37 +0000 (16:47 +0000)
lib/xalloc.h

index 24b2d58040e1705b98785d02882d5294869e848c..b743d6843484b214abb668f29a37bab843f6ee61 100644 (file)
@@ -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.