]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use libc reallocarray in eloop if we have it.
authorRoy Marples <roy@marples.name>
Fri, 6 May 2016 20:51:37 +0000 (20:51 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 May 2016 20:51:37 +0000 (20:51 +0000)
configure
eloop.c

index 457ff08244771bfd3662bc5ee0f3c100f4a9b2d6..b5af065599c634d1659398587969782c22a1f8bc 100755 (executable)
--- a/configure
+++ b/configure
@@ -917,6 +917,8 @@ fi
 if [ "$REALLOCARRAY" = no ]; then
        echo "COMPAT_SRCS+=     compat/reallocarray.c" >>$CONFIG_MK
        echo "#include          \"compat/reallocarray.h\"">>$CONFIG_H
+else
+       echo "#define HAVE_REALLOCARRAY" >>$CONFIG_H
 fi
 
 if [ -z "$POLL" ]; then
diff --git a/eloop.c b/eloop.c
index 13d79642f66a7a227b62958d1e037733d3bede1f..c72f0c5b4ca838a965fae9d2a8fe854fef8f5625 100644 (file)
--- a/eloop.c
+++ b/eloop.c
@@ -181,10 +181,11 @@ struct eloop {
        int exitcode;
 };
 
+#ifdef HAVE_REALLOCARRAY
+#define        eloop_realloca  reallocarray
+#else
 /* Handy routing to check for potential overflow.
- * reallocarray(3) and reallocarr(3) are not portable and this
- * implementation is smaller than using either in libc in
- * the final binary size. */
+ * reallocarray(3) and reallocarr(3) are not portable. */
 #define SQRT_SIZE_MAX (((size_t)1) << (sizeof(size_t) * CHAR_BIT / 2))
 static void *
 eloop_realloca(void *ptr, size_t n, size_t size)
@@ -196,6 +197,7 @@ eloop_realloca(void *ptr, size_t n, size_t size)
        }
        return realloc(ptr, n * size);
 }
+#endif
 
 #ifdef HAVE_POLL
 static void