#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 NMH_UNUSED(i) (void) i
#else
#define NORETURN
#define CHECK_PRINTF(fmt, arg)
+#define ALLOC_SIZE(n)
+#define ALLOC_SIZE2(m, n)
#define NMH_UNUSED(i) i
#endif
#define PLURALS(n) (plurals + ((n) == 1))
/* Call malloc(3), exiting on NULL return. */
-void *mh_xmalloc(size_t size);
+void *mh_xmalloc(size_t size) ALLOC_SIZE(1);
/* Call realloc(3), exiting on NULL return. */
-void *mh_xrealloc(void *ptr, size_t size);
+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);
+void *mh_xcalloc(size_t nelem, size_t elsize) ALLOC_SIZE2(1, 2);
/* Duplicate a NUL-terminated string, exit on failure. */
char *mh_xstrdup(const char *src);
#include <string.h>
#include <stdio.h>
-#include <h/utils.h>
-
#if ! defined HAVE_MKSTEMPS
# define HAVE_MKSTEMPS 0
#endif /* ! HAVE_MKSTEMPS */
#if NMH
#include <h/mh.h>
+#include <h/utils.h>
#if HAVE_MKSTEMPS
# define MHFIXMSG_SWITCHES \