+2020-10-19 Bruno Haible <bruno@clisp.org>
+
+ xalloc-die: Fix link error with Solaris cc (regression 2020-07-27).
+ * lib/xalloc.h (xalloc_die): Don't declare if GNULIB_XALLOC_DIE is 0.
+ (xmalloc, xzalloc, xcalloc, xrealloc, x2realloc, xmemdup, xstrdup,
+ XMALLOC, XNMALLOC, XZALLOC, XCALLOC, xnmalloc, xnrealloc, x2nrealloc,
+ xcharalloc): Don't declare/define if GNULIB_XALLOC is 0.
+ * modules/xalloc (configure.ac): Define GNULIB_XALLOC.
+ * modules/xalloc-die (configure.ac): Define GNULIB_XALLOC_DIE.
+
2020-10-18 Bruno Haible <bruno@clisp.org>
ssfmalloc: Add tests.
# define XALLOC_INLINE _GL_INLINE
#endif
+
#ifdef __cplusplus
extern "C" {
#endif
+#if GNULIB_XALLOC_DIE
+
/* This function is always triggered when memory is exhausted.
It must be defined by the application, either explicitly
or by using gnulib's xalloc-die module. This is the
memory allocation failure. */
/*extern*/ _Noreturn void xalloc_die (void);
+#endif /* GNULIB_XALLOC_DIE */
+
+#if GNULIB_XALLOC
+
void *xmalloc (size_t s)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
void *xzalloc (size_t s)
/* Allocate an object of type T dynamically, with error checking. */
/* extern t *XMALLOC (typename t); */
-#define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
+# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
/* Allocate memory for N elements of type T, with error checking. */
/* extern t *XNMALLOC (size_t n, typename t); */
-#define XNMALLOC(n, t) \
- ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
+# define XNMALLOC(n, t) \
+ ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
/* Allocate an object of type T dynamically, with error checking,
and zero it. */
/* extern t *XZALLOC (typename t); */
-#define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
+# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
/* Allocate memory for N elements of type T, with error checking,
and zero it. */
/* extern t *XCALLOC (size_t n, typename t); */
-#define XCALLOC(n, t) \
- ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
+# define XCALLOC(n, t) \
+ ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
/* Allocate an array of N objects, each with S bytes of memory,
return XNMALLOC (n, char);
}
+#endif /* GNULIB_XALLOC */
+
+
#ifdef __cplusplus
}
+#endif
+
+
+#if GNULIB_XALLOC && defined __cplusplus
/* C++ does not allow conversions from void * to other pointer types
without a cast. Use templates to work around the problem when
return (T *) xmemdup ((void const *) p, s);
}
-#endif
+#endif /* GNULIB_XALLOC && C++ */
+
_GL_INLINE_HEADER_END