summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-09-22 06:33:40 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-09-22 06:33:40 +0000
commit99eda9943e4879b069959ddad65dfb832727f9a6 (patch)
tree13bfc3bf1aba2d7ab2104ab930ecda5fe62a2185 /src
parentfe4ed6c408ab3a70c19bf549f5e5079db40d02ca (diff)
downloadcoreutils-99eda9943e4879b069959ddad65dfb832727f9a6.tar.xz
(X2NREALLOC, X2REALLOC): Moved here from
../lib/xalloc.h, with args properly parenthesized, and using verify_expr rather than the old VERIFY_EXPR.
Diffstat (limited to 'src')
-rw-r--r--src/system.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/system.h b/src/system.h
index b9aeec0aa..e18d99d86 100644
--- a/src/system.h
+++ b/src/system.h
@@ -513,6 +513,20 @@ uid_t getuid ();
#endif
#include "xalloc.h"
+#include "verify.h"
+
+/* 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.
+ So use this macro instead of using x2realloc directly. */
+#define X2REALLOC(P, PN) (verify_expr (sizeof *(P) == 1), x2realloc (P, PN))
#if ! defined HAVE_MEMPCPY && ! defined mempcpy
/* Be CAREFUL that there are no side effects in N. */
@@ -585,7 +599,6 @@ enum
_(" --version output version information and exit\n")
#include "closeout.h"
-#include "verify.h"
#include "version-etc.h"
#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \