From: Roy Marples Date: Fri, 6 May 2016 20:51:37 +0000 (+0000) Subject: Use libc reallocarray in eloop if we have it. X-Git-Tag: v6.11.0~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e98a2b1a83d3575fd787a16cdfb55b7df99d772;p=thirdparty%2Fdhcpcd.git Use libc reallocarray in eloop if we have it. --- diff --git a/configure b/configure index 457ff082..b5af0655 100755 --- 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 13d79642..c72f0c5b 100644 --- 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