zlib 1.0-pre

This commit is contained in:
Mark Adler
2011-09-09 23:13:27 -07:00
parent 56bcb184fa
commit 8a2acbffc8
32 changed files with 588 additions and 1274 deletions

40
zutil.c
View File

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