提交 25e53255 编写于 作者: M Mark Adler

zlib 0.95

上级 23c69f10
ChangeLog file for zlib
Changes in 0.95 (16 Aug 95)
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).
- default window size is same for compression and decompression
(it's now sufficient to set MAX_WBITS in zconf.h).
- voidp -> voidpf and voidnp -> voidp (for consistency with other
typedefs and because voidnp was not near in large model).
Changes in 0.94 (13 Aug 95)
- support MSDOS medium model
- fix deflate with flush (could sometimes generate bad output)
......@@ -10,6 +20,7 @@ Changes in 0.94 (13 Aug 95)
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
- avoid complex expression in infcodes.c triggering Turbo C bug
- work around a problem with gcc on Alpha (in INSERT_STRING)
- don't use inline functions (problem with some gcc versions)
- allow renaming of Byte, uInt, etc... with #define.
......
......@@ -2,6 +2,7 @@
# Borland C++ ************ UNTESTED ***********
# To use, do "make -fmakefile.bor"
# To compile in small model, set below: MODEL=-ms
# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
......
......@@ -2,6 +2,7 @@
# Microsoft C 5.1 or later
# To use, do "make makefile.msc"
# To compile in small model, set below: MODEL=-AS
# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
......
......@@ -2,10 +2,11 @@
# TurboC 2.0
# To use, do "make -fmakefile.tc"
# To compile in small model, set below: MODEL=-ms
# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3
# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
......@@ -13,6 +14,7 @@
# ------------- Turbo C 2.0 -------------
MODEL=-ml
# CFLAGS=-O2 -G -Z $(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
CFLAGS=-O2 -G -Z $(MODEL)
CC=tcc -I\tc\include
LD=tcc -L\tc\lib
......
zlib 0.94 is a beta version of a general purpose compression library.
Unless new bugs are found it will be released again as the first official
version (1.0). This version has no known bugs.
zlib 0.95 is a beta version of a general purpose compression library.
This should be the last version before the first official
version (1.0), so please test it now. (At least compile and run it with
"make test"). This version has no known bugs.
The data format used by the zlib library is described in the
files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
......@@ -8,31 +9,29 @@ in ftp.uu.net:/pub/archiving/zip/doc.
All functions of the compression library are documented in the file
zlib.h. A usage example of the library is given in the file example.c
which also tests that the library is working correctly.
which also tests that the library is working correctly. Another
example is given in the file minigzip.c.
To compile all files and run the test program, just type: make test
(For MSDOS, use one of the special makefiles such as Makefile.msc.)
(For MSDOS, use one of the special makefiles such as Makefile.msc;
for VMS, use Make_vms.com or descrip.mms.)
To install the zlib library (libz.a) in /usr/local/lib, type: make install
To install in a different directory, use for example:
make install prefix=$HOME
This will install in $HOME/lib instead of /usr/local/lib.
The changes made in version 0.94 are documented in the file ChangeLog.
The main changes since 0.93 are:
- support MSDOS small and medium model
- fix deflate with flush (could sometimes generate bad output)
- fix deflateReset (zlib header was incorrectly suppressed)
- added support for VMS
- allow a compression level in gzopen()
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
The changes made in version 0.95 are documented in the file ChangeLog.
The main changes since 0.94 are:
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).
For MSDOS, the small and medium models are supported only for Microsoft C.
(It should be easy to support them for Borland C also, but I don't have
a recent Borland compiler to test with.) The small model currently works
for Turbo/Borland C but only with reduced performance to avoid any far
allocation (tested with -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3).
For MSDOS, the small and medium models have been tested only with Microsoft C.
(This should now work for Borland C also, but I don't have a recent Borland
compiler to test with.) The small model was tested with Turbo C but only with
reduced performance to avoid any far allocation; it was tested with
-DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
(C) 1995 Jean-loup Gailly and Mark Adler
......
......@@ -524,8 +524,8 @@ local int longest_match(s, cur_match)
* Try with and without -DUNALIGNED_OK to check.
*/
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
register ush scan_start = *(ush*)scan;
register ush scan_end = *(ush*)(scan+best_len-1);
register ush scan_start = *(ushf*)scan;
register ush scan_end = *(ushf*)(scan+best_len-1);
#else
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
register Byte scan_end1 = scan[best_len-1];
......@@ -554,8 +554,8 @@ local int longest_match(s, cur_match)
/* This code assumes sizeof(unsigned short) == 2. Do not use
* UNALIGNED_OK if your compiler uses a different size.
*/
if (*(ush*)(match+best_len-1) != scan_end ||
*(ush*)match != scan_start) continue;
if (*(ushf*)(match+best_len-1) != scan_end ||
*(ushf*)match != scan_start) continue;
/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
......@@ -569,10 +569,10 @@ local int longest_match(s, cur_match)
Assert(scan[2] == match[2], "scan[2]?");
scan++, match++;
do {
} while (*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
*(ush*)(scan+=2) == *(ush*)(match+=2) &&
} while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
scan < strend);
/* The funny "do {}" generates better code on most compilers */
......@@ -621,7 +621,7 @@ local int longest_match(s, cur_match)
best_len = len;
if (len >= s->nice_match) break;
#ifdef UNALIGNED_OK
scan_end = *(ush*)(scan+best_len-1);
scan_end = *(ushf*)(scan+best_len-1);
#else
scan_end1 = scan[best_len-1];
scan_end = scan[best_len];
......
......@@ -233,6 +233,7 @@ typedef struct internal_state {
ulg static_len; /* bit length of current block with static trees */
ulg compressed_len; /* total bit length of compressed file */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
ulg bits_sent; /* bit length of the compressed data */
......
......@@ -277,7 +277,7 @@ int main(argc, argv)
fprintf(stderr, "incompatible zlib version\n");
exit(1);
} else if (zstrcmp(zlib_version, ZLIB_VERSION) != 0) {
} else if (strcmp(zlib_version, ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version\n");
}
test_compress();
......
......@@ -234,7 +234,7 @@ gzFile gzdopen (fd, mode)
*/
int gzread (file, buf, len)
gzFile file;
voidnp buf;
voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
......@@ -292,7 +292,7 @@ int gzread (file, buf, len)
*/
int gzwrite (file, buf, len)
gzFile file;
voidnp buf;
voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
......
......@@ -25,14 +25,14 @@ local int huft_build OF((
uIntf *, /* maximum lookup bits (returns actual) */
z_stream *)); /* for zalloc function */
local voidp falloc OF((
voidp, /* opaque pointer (not used) */
local voidpf falloc OF((
voidpf, /* opaque pointer (not used) */
uInt, /* number of items */
uInt)); /* size of item */
local void ffree OF((
voidp q, /* opaque pointer (not used) */
voidp p)); /* what to free (not used) */
voidpf q, /* opaque pointer (not used) */
voidpf p)); /* what to free (not used) */
/* Tables for deflate from PKZIP's appnote.txt. */
local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
......@@ -377,8 +377,8 @@ local inflate_huft *fixed_tl;
local inflate_huft *fixed_td;
local voidp falloc(q, n, s)
voidp q; /* opaque pointer (not used) */
local voidpf falloc(q, n, s)
voidpf q; /* opaque pointer (not used) */
uInt n; /* number of items */
uInt s; /* size of item */
{
......@@ -386,13 +386,13 @@ uInt s; /* size of item */
"inflate_trees falloc overflow");
if (q) s++; /* to make some compilers happy */
fixed_left -= n;
return (voidp)(fixed_mem + fixed_left);
return (voidpf)(fixed_mem + fixed_left);
}
local void ffree(q, p)
voidp q;
voidp p;
voidpf q;
voidpf p;
{
Assert(0, "inflate_trees ffree called!");
if (q) q = p; /* to make some compilers happy */
......
......@@ -143,9 +143,9 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
local void compress_block OF((deflate_state *s, ct_data *ltree,
ct_data *dtree));
local void set_data_type OF((deflate_state *s));
local void send_bits OF((deflate_state *s, int value, int length));
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
int header));
......@@ -166,6 +166,63 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
* used.
*/
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
#ifdef DEBUG
local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length)
deflate_state *s;
int value; /* value to send */
int length; /* number of bits */
{
Tracev((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
s->bits_sent += (ulg)length;
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
* unused bits in value.
*/
if (s->bi_valid > (int)Buf_size - length) {
s->bi_buf |= (value << s->bi_valid);
put_short(s, s->bi_buf);
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
s->bi_valid += length - Buf_size;
} else {
s->bi_buf |= value << s->bi_valid;
s->bi_valid += length;
}
}
#else /* !DEBUG */
#define send_bits(s, value, length) \
{ int len = length;\
if (s->bi_valid > (int)Buf_size - len) {\
int val = value;\
s->bi_buf |= (val << s->bi_valid);\
put_short(s, s->bi_buf);\
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
s->bi_valid += len - Buf_size;\
} else {\
s->bi_buf |= (value) << s->bi_valid;\
s->bi_valid += len;\
}\
}
#endif /* DEBUG */
#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
......@@ -259,6 +316,7 @@ void ct_init(s)
s->bi_buf = 0;
s->bi_valid = 0;
s->last_eob_len = 8; /* enough lookahead for inflate */
#ifdef DEBUG
s->bits_sent = 0L;
#endif
......@@ -739,7 +797,12 @@ void ct_stored_block(s, buf, stored_len, eof)
}
/* ===========================================================================
* Send one empty static block to give enough lookahead for inflate
* Send one empty static block to give enough lookahead for inflate.
* This takes 10 bits, of which 7 may remain in the bit buffer.
* The current inflate code requires 9 bits of lookahead. If the EOB
* code for the previous block was coded on 5 bits or less, inflate
* may have only 5+3 bits of lookahead to decode this EOB.
* (There are no problems if the previous block is stored or fixed.)
*/
void ct_align(s)
deflate_state *s;
......@@ -747,6 +810,18 @@ void ct_align(s)
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
bi_flush(s);
/* Of the 10 bits for the empty block, we have already sent
* (10 - bi_valid) bits. The lookahead for the EOB of the previous
* block was thus its length plus what we have just sent.
*/
if (s->last_eob_len + 10 - s->bi_valid < 9) {
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
s->compressed_len += 10L;
bi_flush(s);
}
s->last_eob_len = 7;
}
/* ===========================================================================
......@@ -950,6 +1025,7 @@ local void compress_block(s, ltree, dtree)
} while (lx < s->last_lit);
send_code(s, END_BLOCK, ltree);
s->last_eob_len = ltree[END_BLOCK].Len;
}
/* ===========================================================================
......@@ -970,44 +1046,6 @@ local void set_data_type(s)
s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII);
}
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
local void send_bits(s, value, length)
deflate_state *s;
int value; /* value to send */
int length; /* number of bits */
{
#ifdef DEBUG
Tracev((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
s->bits_sent += (ulg)length;
#endif
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
* unused bits in value.
*/
if (s->bi_valid > (int)Buf_size - length) {
s->bi_buf |= (value << s->bi_valid);
put_short(s, s->bi_buf);
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
s->bi_valid += length - Buf_size;
} else {
s->bi_buf |= value << s->bi_valid;
s->bi_valid += length;
}
}
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
......@@ -1026,7 +1064,24 @@ local unsigned bi_reverse(code, len)
}
/* ===========================================================================
* Write out any remaining bits in an incomplete byte.
* Flush the bit buffer, keeping at most 7 bits in it.
*/
local void bi_flush(s)
deflate_state *s;
{
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
s->bi_buf = 0;
s->bi_valid = 0;
} else if (s->bi_valid >= 8) {
put_byte(s, (Byte)s->bi_buf);
s->bi_buf >>= 8;
s->bi_valid -= 8;
}
}
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
local void bi_windup(s)
deflate_state *s;
......@@ -1053,7 +1108,8 @@ local void copy_block(s, buf, len, header)
unsigned len; /* its length */
int header; /* true if block header must be written */
{
bi_windup(s); /* align on byte boundary */
bi_windup(s); /* align on byte boundary */
s->last_eob_len = 8; /* enough lookahead for inflate */
if (header) {
put_short(s, (ush)len);
......
......@@ -85,37 +85,42 @@
# endif
#endif
#if defined(M_I86SM) || defined(M_I86MM) /* model independent MSC functions */
# define zstrcpy _fstrcpy
# define zstrcat _fstrcat
# define zstrlen _fstrlen
# define zstrcmp _fstrcmp
# define FAR __far
#else
# define zstrcpy strcpy
# define zstrcat strcat
# define zstrlen strlen
# define zstrcmp strcmp
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */
# ifdef _MSC_VER
# define FAR __far
# else
# define FAR far
# endif
#endif
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# define FAR __far /* completely untested, just a best guess */
#endif
#ifndef FAR
# define FAR
#endif
typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
typedef Byte FAR Bytef;
typedef char FAR charf;
typedef Byte FAR Bytef;
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void FAR *voidp;
typedef void *voidnp;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte FAR *voidp;
typedef Byte *voidnp;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#endif /* _ZCONF_H */
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 0.94, Aug 13th, 1995.
version 0.95, Aug 16th, 1995.
Copyright (C) 1995 Jean-loup Gailly and Mark Adler
......@@ -28,7 +28,7 @@
#include "zconf.h"
#define ZLIB_VERSION "0.94"
#define ZLIB_VERSION "0.95"
/*
The 'zlib' compression library provides in-memory compression and
......@@ -49,8 +49,8 @@
(providing more output space) before each call.
*/
typedef voidp (*alloc_func) OF((voidp opaque, uInt items, uInt size));
typedef void (*free_func) OF((voidp opaque, voidp address));
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
typedef void (*free_func) OF((voidpf opaque, voidpf address));
struct internal_state;
......@@ -510,7 +510,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen,
*/
typedef voidnp gzFile;
typedef voidp gzFile;
extern gzFile gzopen OF((char *path, char *mode));
/*
......@@ -533,7 +533,7 @@ extern gzFile gzdopen OF((int fd, char *mode));
the (de)compression state.
*/
extern int gzread OF((gzFile file, voidnp buf, unsigned len));
extern int gzread OF((gzFile file, voidp buf, unsigned len));
/*
Reads the given number of uncompressed bytes from the compressed file.
If the input file was not in gzip format, gzread copies the given number
......@@ -541,7 +541,7 @@ extern int gzread OF((gzFile file, voidnp buf, unsigned len));
gzread returns the number of uncompressed bytes actually read (0 for
end of file, -1 for error). */
extern int gzwrite OF((gzFile file, voidnp buf, unsigned len));
extern int gzwrite OF((gzFile file, voidp buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes actually written
......
......@@ -38,8 +38,8 @@ void z_error (m)
#ifndef HAVE_MEMCPY
void zmemcpy(dest, source, len)
Byte* dest;
Byte* source;
Bytef* dest;
Bytef* source;
uInt len;
{
if (len == 0) return;
......@@ -49,7 +49,7 @@ void zmemcpy(dest, source, len)
}
void zmemzero(dest, len)
Byte* dest;
Bytef* dest;
uInt len;
{
if (len == 0) return;
......@@ -59,8 +59,10 @@ void zmemzero(dest, len)
}
#endif
#if defined(__TURBOC__) && !defined(__SMALL__)
#if defined( __TURBOC__) && !defined(__SMALL__) && !defined(__MEDIUM__)
/* Small and medium model are for now limited to near allocation with
* reduced MAX_WBITS and MAX_MEM_LEVEL
*/
# define MY_ZCALLOC
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
......@@ -75,8 +77,8 @@ void zmemzero(dest, len)
local int next_ptr = 0;
typedef struct ptr_table_s {
voidp org_ptr;
voidp new_ptr;
voidpf org_ptr;
voidpf new_ptr;
} ptr_table;
local ptr_table table[MAX_PTR];
......@@ -87,9 +89,9 @@ local ptr_table table[MAX_PTR];
* a protected system like OS/2. Use Microsoft C instead.
*/
voidp zcalloc (voidp opaque, unsigned items, unsigned size)
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
voidp buf = opaque; /* just to make some compilers happy */
voidpf buf = opaque; /* just to make some compilers happy */
ulg bsize = (ulg)items*size;
if (bsize < 65536L) {
......@@ -108,7 +110,7 @@ voidp zcalloc (voidp opaque, unsigned items, unsigned size)
return buf;
}
void zcfree (voidp opaque, voidp ptr)
void zcfree (voidpf opaque, voidpf ptr)
{
int n;
if (*(ush*)&ptr != 0) { /* object < 64K */
......@@ -131,7 +133,8 @@ void zcfree (voidp opaque, voidp ptr)
}
#endif /* __TURBOC__ */
#if defined(MSDOS) && !defined(__TURBOC__) /* MSC */
#if defined(M_I86SM)||defined(M_I86MM)||defined(M_I86CM)||defined(M_I86LM)
/* Microsoft C */
# define MY_ZCALLOC
......@@ -140,13 +143,13 @@ void zcfree (voidp opaque, voidp ptr)
# define _hfree hfree
#endif
voidp zcalloc (voidp opaque, unsigned items, unsigned size)
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
if (opaque) opaque = 0; /* to make compiler happy */
return _halloc((long)items, size);
}
void zcfree (voidp opaque, voidp ptr)
void zcfree (voidpf opaque, voidpf ptr)
{
if (opaque) opaque = 0; /* to make compiler happy */
_hfree(ptr);
......@@ -158,21 +161,21 @@ void zcfree (voidp opaque, voidp ptr)
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
#ifndef __GO32__
extern voidp calloc OF((uInt items, uInt size));
extern void free OF((voidp ptr));
extern voidp calloc OF((uInt items, uInt size));
extern void free OF((voidpf ptr));
#endif
voidp zcalloc (opaque, items, size)
voidp opaque;
voidpf zcalloc (opaque, items, size)
voidpf opaque;
unsigned items;
unsigned size;
{
return calloc(items, size);
return (voidpf)calloc(items, size);
}
void zcfree (opaque, ptr)
voidp opaque;
voidp ptr;
voidpf opaque;
voidpf ptr;
{
free(ptr);
}
......
......@@ -46,7 +46,7 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
#define DEFLATED 8
#ifndef DEF_WBITS
# define DEF_WBITS 15
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
......@@ -72,7 +72,7 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
# define OS_CODE 0x00
# ifdef __TURBOC__
# include <alloc.h>
# else /* MSC */
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
......@@ -130,23 +130,29 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
# define zstrerror(errnum) ""
#endif
#if defined(pyr) && !defined(NO_MEMCPY)
#if defined(pyr)
# define NO_MEMCPY
#endif
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef M_I86MM /* MSC medium model */
# if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */
# define zmemcpy _fmemcpy
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# else
# define zmemcpy memcpy
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern void zmemcpy OF((Byte* dest, Byte* source, uInt len));
extern void zmemzero OF((Byte* dest, uInt len));
extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
......@@ -175,12 +181,12 @@ typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
extern void z_error OF((char *m));
voidp zcalloc OF((voidp opaque, unsigned items, unsigned size));
void zcfree OF((voidp opaque, voidp ptr));
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidp)(addr))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* _Z_UTIL_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册