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)
/* 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 -- */
/*
/* 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);
} 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