From 8a2acbffc86012de3523ecf91db2c4ea1b1c4ea2 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:13:27 -0700 Subject: zlib 1.0-pre --- zutil.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'zutil.c') diff --git a/zutil.c b/zutil.c index f7bd6e5..97e74ea 100644 --- a/zutil.c +++ b/zutil.c @@ -1,5 +1,5 @@ /* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-1996 Jean-loup Gailly. + * Copyright (C) 1995 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,18 +15,16 @@ struct internal_state {int dummy;}; /* for buggy compilers */ extern void exit OF((int)); #endif -const char *zlib_version = ZLIB_VERSION; - -const char *z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ +char *zlib_version = ZLIB_VERSION; + +char *z_errmsg[] = { +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ ""}; @@ -62,9 +60,9 @@ void zmemzero(dest, len) #endif #ifdef __TURBOC__ -#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) -/* Small and medium model in Turbo C are for now limited to near allocation - * with reduced MAX_WBITS and MAX_MEM_LEVEL +#if !defined(__SMALL__) && !defined(__MEDIUM__) && !defined(__32BIT__) +/* Small and medium model are for now limited to near allocation with + * reduced MAX_WBITS and MAX_MEM_LEVEL */ # define MY_ZCALLOC @@ -102,6 +100,9 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) */ if (bsize < 65520L) { buf = farmalloc(bsize); +#ifdef DEBUG + zmemzero(buf, (uInt)bsize); +#endif if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); @@ -113,6 +114,10 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; +#ifdef DEBUG + zmemzero(buf, (uInt)65535); + ((uch*)buf)[65535] = 0; +#endif return buf; } @@ -141,8 +146,7 @@ void zcfree (voidpf opaque, voidpf ptr) #endif /* __TURBOC__ */ -#if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__)) -/* Microsoft C */ +#ifdef M_I86 /* Microsoft C */ # define MY_ZCALLOC @@ -178,7 +182,6 @@ voidpf zcalloc (opaque, items, size) unsigned items; unsigned size; { - if (opaque) opaque = 0; /* to make compiler happy */ return (voidpf)calloc(items, size); } @@ -186,7 +189,6 @@ void zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { - if (opaque) opaque = 0; /* to make compiler happy */ free(ptr); } -- cgit v1.2.3-55-g6feb