From: Hans Kristian Rosbach Date: Tue, 3 Nov 2015 14:41:15 +0000 (+0100) Subject: Apply Mark Adlers fix to remove the need for -lbsd for reallocf, and X-Git-Tag: 1.9.9-b1~793^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e02cb852394e6ef24d5556c9e62ee58b259a0eda;p=thirdparty%2Fzlib-ng.git Apply Mark Adlers fix to remove the need for -lbsd for reallocf, and remove our detection of reallocf. --- diff --git a/configure b/configure index dd0a20c4f..2712265c9 100755 --- a/configure +++ b/configure @@ -601,47 +601,6 @@ EOF fi fi -# check where reallocf is defined -cat > $test.c << EOF -#include - -int main() -{ - void *p = reallocf(NULL, 255); - return p != NULL; -} -EOF -if try $CC -c $CFLAGS -Werror $test.c; then - echo "Checking where reallocf is defined... stdlib.h" | tee -a configure.log -else -cat > $test.c << EOF -#include - -int main() -{ - void *p = reallocf(NULL, 255); - return p != NULL; -} -EOF -if try $CC -c $CFLAGS -Werror $test.c; then - echo "Checking where reallocf is defined... bsd/stdlib.h" | tee -a configure.log - CFLAGS="$CFLAGS -DHAVE_BSD_STDLIB" -else - echo "Checking where reallocf is defined... Not found!" | tee -a configure.log -fi; -fi; - -# check if we need -lbsd for reallocf -BSDLIBS= -if ($CC $CFLAGS -o $test $test.c) 2>> configure.log ; then - echo "Checking for reallocf... Yes." | tee -a configure.log -elif ($CC $CFLAGS -o $test $test.c -lbsd) 2>> configure.log ; then - BSDLIBS=-lbsd - echo "Checking for reallocf... -lbsd" | tee -a configure.log -else - echo "Checking for reallocf... No." | tee -a configure.log -fi; - # Check for __builtin_ctzl() support in compiler cat > $test.c << EOF int main(void) diff --git a/test/infcover.c b/test/infcover.c index fe4bf2de6..5555a155f 100644 --- a/test/infcover.c +++ b/test/infcover.c @@ -6,11 +6,7 @@ /* to use, do: ./configure --cover && make cover */ #include -#ifdef HAVE_BSD_STDLIB -# include -#else -# include -#endif +#include #include #include #include "zlib.h" @@ -21,18 +17,6 @@ #include "inftrees.h" #include "inflate.h" -/* reallocf is BSD-specific */ -#ifndef reallocf -static void *reallocf(void *ptr, size_t size) -{ - void *ret = realloc(ptr, size); - if ((ret == NULL) && (ptr != NULL) && (size != 0)) - free(ptr); - return ret; -} -#endif - - /* -- memory tracking routines -- */ /* @@ -251,14 +235,14 @@ static void mem_done(z_stream *strm, char *prefix) /* Decode a hexadecimal string, set *len to length, in[] to the bytes. This decodes liberally, in that hex digits can be adjacent, in which case two in - a row writes a byte. Or they can delimited by any non-hex character, where - the delimiters are ignored except when a single hex digit is followed by a - delimiter in which case that single digit writes a byte. The returned - data is allocated and must eventually be freed. NULL is returned if out of - memory. If the length is not needed, then len can be NULL. */ + a row writes a byte. Or they can be delimited by any non-hex character, + where the delimiters are ignored except when a single hex digit is followed + by a delimiter, where that single digit writes a byte. The returned data is + allocated and must eventually be freed. NULL is returned if out of memory. + If the length is not needed, then len can be NULL. */ static unsigned char *h2b(const char *hex, unsigned *len) { - unsigned char *in; + unsigned char *in, *re; unsigned next, val; in = malloc((strlen(hex) + 1) >> 1); @@ -282,8 +266,8 @@ static unsigned char *h2b(const char *hex, unsigned *len) } while (*hex++); /* go through the loop with the terminating null */ if (len != NULL) *len = next; - in = reallocf(in, next); - return in; + re = realloc(in, next); + return re == NULL ? in : re; } /* generic inflate() run, where hex is the hexadecimal input data, what is the