reallocarray() is not specified by any standard and may be missing from
older versions of glibc.
Fixes #2491
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
posix_fadvise \
prctl \
qsort_r \
+ reallocarray \
rpmatch \
scandirat \
sched_setattr \
#define SINT_MAX(t) (((t)1 << (sizeof(t) * 8 - 2)) - (t)1 + ((t)1 << (sizeof(t) * 8 - 2)))
+#ifndef HAVE_REALLOCARRAY
+static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
+{
+ size_t s = nmemb * size;
+
+ if (nmemb != 0 && s / nmemb != size) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(ptr, s);
+}
+#endif
+
#endif /* UTIL_LINUX_C_H */
posix_fadvise
prctl
qsort_r
+ reallocarray
rpmatch
scandirat
setprogname