]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Apply Mark Adlers fix to remove the need for -lbsd for reallocf, and
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 3 Nov 2015 14:41:15 +0000 (15:41 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 3 Nov 2015 14:41:15 +0000 (15:41 +0100)
remove our detection of reallocf.

configure
test/infcover.c

index dd0a20c4f85244dafca30e2726136e4e7d818dfe..2712265c92e3e1c33afcc44a8d7e0a9eaf44fdcb 100755 (executable)
--- a/configure
+++ b/configure
@@ -601,47 +601,6 @@ EOF
   fi
 fi
 
-# check where reallocf is defined
-cat > $test.c << EOF
-#include <stdlib.h>
-
-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 <bsd/stdlib.h>
-
-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)
index fe4bf2de65c6c4bf31758c518ff8a56d86ffc76d..5555a155fc3213d642f880036dfd2d52556e3d9e 100644 (file)
@@ -6,11 +6,7 @@
 /* to use, do: ./configure --cover && make cover */
 
 #include <stdio.h>
-#ifdef HAVE_BSD_STDLIB
-#  include <bsd/stdlib.h>
-#else
-#  include <stdlib.h>
-#endif
+#include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include "zlib.h"
 #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