From 40db6abec10689d2824e5ac627f94aab924b8b8a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Jul 2005 16:47:37 +0000 Subject: (X2NREALLOC): Define. --- lib/xalloc.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/xalloc.h') 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. -- cgit v1.2.3-54-g00ecf