+2021-07-28 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac (AC_CHECK_DECLS): Add reallocarray check.
+
2021-05-22 Mark Wielaard <mark@klomp.org>
* configure.ac (AC_INIT): Set version to 0.185.
AC_CHECK_DECLS([mempcpy],[],[],
[#define _GNU_SOURCE
#include <string.h>])
+AC_CHECK_DECLS([reallocarray],[],[],
+ [#define _GNU_SOURCE
+ #include <stdlib.h>])
AC_CHECK_FUNCS([process_vm_readv])
+2021-07-28 Mark Wielaard <mark@klomp.org>
+
+ * system.h (reallocarray): New static inline fallback function.
+
2021-04-19 Martin Liska <mliska@suse.cz>
* system.h (startswith): New function.
#include <byteswap.h>
#include <unistd.h>
#include <string.h>
+#include <stdlib.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define LE32(n) (n)
((void *) ((char *) memcpy (dest, src, n) + (size_t) n))
#endif
+#if !HAVE_DECL_REALLOCARRAY
+static inline void *
+reallocarray (void *ptr, size_t nmemb, size_t size)
+{
+ if (size > 0 && nmemb > SIZE_MAX / size)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc (ptr, nmemb * size);
+}
+#endif
+
/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
static inline int