]> diplodocus.org Git - nmh/commitdiff
Use C99's variable-argument preprocessor macros for ALLOC_SIZE.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 26 Aug 2017 17:41:42 +0000 (18:41 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 26 Aug 2017 17:41:42 +0000 (18:41 +0100)
ALLOC_SIZE2() can be deleted.

h/mh.h
h/utils.h

diff --git a/h/mh.h b/h/mh.h
index 3ee706b..3093df1 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -35,16 +35,14 @@ typedef unsigned char  boolean;  /* not int so we can pack in a structure */
 #if __GNUC__ > 2
 #define NORETURN __attribute__((__noreturn__))
 #define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
 #if __GNUC__ > 2
 #define NORETURN __attribute__((__noreturn__))
 #define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
-#define ALLOC_SIZE(n) __attribute__((alloc_size(n)))
-#define ALLOC_SIZE2(m, n) __attribute__((alloc_size(m, n)))
+#define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
 #define CONST __attribute__((const))
 #define MALLOC __attribute__((malloc))
 #define NMH_UNUSED(i) (void) i
 #else
 #define NORETURN
 #define CHECK_PRINTF(fmt, arg)
 #define CONST __attribute__((const))
 #define MALLOC __attribute__((malloc))
 #define NMH_UNUSED(i) (void) i
 #else
 #define NORETURN
 #define CHECK_PRINTF(fmt, arg)
-#define ALLOC_SIZE(n)
-#define ALLOC_SIZE2(m, n)
+#define ALLOC_SIZE(...)
 #define CONST
 #define MALLOC
 #define NMH_UNUSED(i) i
 #define CONST
 #define MALLOC
 #define NMH_UNUSED(i) i
index f8b2198..597569b 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -17,7 +17,7 @@ void *mh_xmalloc(size_t size) MALLOC ALLOC_SIZE(1);
 void *mh_xrealloc(void *ptr, size_t size) ALLOC_SIZE(2);
 
 /* Call calloc(3), exiting on NULL return. */
 void *mh_xrealloc(void *ptr, size_t size) ALLOC_SIZE(2);
 
 /* Call calloc(3), exiting on NULL return. */
-void *mh_xcalloc(size_t nelem, size_t elsize) MALLOC ALLOC_SIZE2(1, 2);
+void *mh_xcalloc(size_t nelem, size_t elsize) MALLOC ALLOC_SIZE(1, 2);
 
 /* Duplicate a NUL-terminated string, exit on failure. */
 char *mh_xstrdup(const char *src) MALLOC;
 
 /* Duplicate a NUL-terminated string, exit on failure. */
 char *mh_xstrdup(const char *src) MALLOC;