[CHG] zlib updated to version 1.2.7

This commit is contained in:
Crayon2000 2012-05-08 01:53:10 +00:00
parent 487d9b544c
commit ebcd466adb
13 changed files with 284 additions and 196 deletions

View file

@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream /* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2006, 2010, 2011 Mark Adler * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
* *
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@ -32,39 +32,17 @@
#define local static #define local static
/* Find a four-byte integer type for crc32_little() and crc32_big(). */
#ifndef NOBYFOUR
# ifdef STDC /* need ANSI C limits.h to determine sizes */
# include <limits.h>
# define BYFOUR
# if (UINT_MAX == 0xffffffffUL)
typedef unsigned int u4;
# else
# if (ULONG_MAX == 0xffffffffUL)
typedef unsigned long u4;
# else
# if (USHRT_MAX == 0xffffffffUL)
typedef unsigned short u4;
# else
# undef BYFOUR /* can't find a four-byte integer type! */
# endif
# endif
# endif
# endif /* STDC */
#endif /* !NOBYFOUR */
/* Definitions for doing the crc four data bytes at a time. */ /* Definitions for doing the crc four data bytes at a time. */
#if !defined(NOBYFOUR) && defined(Z_U4)
# define BYFOUR
#endif
#ifdef BYFOUR #ifdef BYFOUR
typedef u4 crc_table_t;
# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long, local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned)); const unsigned char FAR *, unsigned));
local unsigned long crc32_big OF((unsigned long, local unsigned long crc32_big OF((unsigned long,
const unsigned char FAR *, unsigned)); const unsigned char FAR *, unsigned));
# define TBLS 8 # define TBLS 8
#else #else
typedef unsigned long crc_table_t;
# define TBLS 1 # define TBLS 1
#endif /* BYFOUR */ #endif /* BYFOUR */
@ -78,10 +56,10 @@ local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
local volatile int crc_table_empty = 1; local volatile int crc_table_empty = 1;
local crc_table_t FAR crc_table[TBLS][256]; local z_crc_t FAR crc_table[TBLS][256];
local void make_crc_table OF((void)); local void make_crc_table OF((void));
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table OF((FILE *, const crc_table_t FAR *)); local void write_table OF((FILE *, const z_crc_t FAR *));
#endif /* MAKECRCH */ #endif /* MAKECRCH */
/* /*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@ -111,9 +89,9 @@ local void make_crc_table OF((void));
*/ */
local void make_crc_table() local void make_crc_table()
{ {
crc_table_t c; z_crc_t c;
int n, k; int n, k;
crc_table_t poly; /* polynomial exclusive-or pattern */ z_crc_t poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */ static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@ -127,11 +105,11 @@ local void make_crc_table()
/* make exclusive-or pattern from polynomial (0xedb88320UL) */ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0; poly = 0;
for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
poly |= (crc_table_t)1 << (31 - p[n]); poly |= (z_crc_t)1 << (31 - p[n]);
/* generate a crc for every 8-bit value */ /* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) { for (n = 0; n < 256; n++) {
c = (crc_table_t)n; c = (z_crc_t)n;
for (k = 0; k < 8; k++) for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1; c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c; crc_table[0][n] = c;
@ -142,11 +120,11 @@ local void make_crc_table()
and then the byte reversal of those as well as the first table */ and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) { for (n = 0; n < 256; n++) {
c = crc_table[0][n]; c = crc_table[0][n];
crc_table[4][n] = REV(c); crc_table[4][n] = ZSWAP32(c);
for (k = 1; k < 4; k++) { for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8); c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c; crc_table[k][n] = c;
crc_table[k + 4][n] = REV(c); crc_table[k + 4][n] = ZSWAP32(c);
} }
} }
#endif /* BYFOUR */ #endif /* BYFOUR */
@ -168,7 +146,7 @@ local void make_crc_table()
if (out == NULL) return; if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const crc_table_t FAR "); fprintf(out, "local const z_crc_t FAR ");
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
write_table(out, crc_table[0]); write_table(out, crc_table[0]);
# ifdef BYFOUR # ifdef BYFOUR
@ -188,7 +166,7 @@ local void make_crc_table()
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table(out, table) local void write_table(out, table)
FILE *out; FILE *out;
const crc_table_t FAR *table; const z_crc_t FAR *table;
{ {
int n; int n;
@ -209,13 +187,13 @@ local void write_table(out, table)
/* ========================================================================= /* =========================================================================
* This function can be used by asm versions of crc32() * This function can be used by asm versions of crc32()
*/ */
const unsigned long FAR * ZEXPORT get_crc_table() const z_crc_t FAR * ZEXPORT get_crc_table()
{ {
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) if (crc_table_empty)
make_crc_table(); make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */ #endif /* DYNAMIC_CRC_TABLE */
return (const unsigned long FAR *)crc_table; return (const z_crc_t FAR *)crc_table;
} }
/* ========================================================================= */ /* ========================================================================= */
@ -237,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
#ifdef BYFOUR #ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) { if (sizeof(void *) == sizeof(ptrdiff_t)) {
u4 endian; z_crc_t endian;
endian = 1; endian = 1;
if (*((unsigned char *)(&endian))) if (*((unsigned char *)(&endian)))
@ -271,17 +249,17 @@ local unsigned long crc32_little(crc, buf, len)
const unsigned char FAR *buf; const unsigned char FAR *buf;
unsigned len; unsigned len;
{ {
register u4 c; register z_crc_t c;
register const u4 FAR *buf4; register const z_crc_t FAR *buf4;
c = (u4)crc; c = (z_crc_t)crc;
c = ~c; c = ~c;
while (len && ((ptrdiff_t)buf & 3)) { while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--; len--;
} }
buf4 = (const u4 FAR *)(const void FAR *)buf; buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
while (len >= 32) { while (len >= 32) {
DOLIT32; DOLIT32;
len -= 32; len -= 32;
@ -311,17 +289,17 @@ local unsigned long crc32_big(crc, buf, len)
const unsigned char FAR *buf; const unsigned char FAR *buf;
unsigned len; unsigned len;
{ {
register u4 c; register z_crc_t c;
register const u4 FAR *buf4; register const z_crc_t FAR *buf4;
c = REV((u4)crc); c = ZSWAP32((z_crc_t)crc);
c = ~c; c = ~c;
while (len && ((ptrdiff_t)buf & 3)) { while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--; len--;
} }
buf4 = (const u4 FAR *)(const void FAR *)buf; buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
buf4--; buf4--;
while (len >= 32) { while (len >= 32) {
DOBIG32; DOBIG32;
@ -338,7 +316,7 @@ local unsigned long crc32_big(crc, buf, len)
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len); } while (--len);
c = ~c; c = ~c;
return (unsigned long)(REV(c)); return (unsigned long)(ZSWAP32(c));
} }
#endif /* BYFOUR */ #endif /* BYFOUR */

View file

@ -2,7 +2,7 @@
* Generated automatically by crc32.c * Generated automatically by crc32.c
*/ */
local const crc_table_t FAR crc_table[TBLS][256] = local const z_crc_t FAR crc_table[TBLS][256] =
{ {
{ {
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,

View file

@ -52,7 +52,7 @@
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
" deflate 1.2.6 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot

View file

@ -12,7 +12,7 @@
# endif # endif
#endif #endif
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) #ifdef HAVE_HIDDEN
# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else #else
# define ZLIB_INTERNAL # define ZLIB_INTERNAL
@ -27,7 +27,11 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#ifdef __TURBOC__ #ifdef _WIN32
# include <stddef.h>
#endif
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
# include <io.h> # include <io.h>
#endif #endif
@ -66,7 +70,6 @@
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf) # if !defined(vsnprintf) && !defined(NO_vsnprintf)
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# include <io.h>
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
# endif # endif
# endif # endif
@ -101,7 +104,7 @@
# include <windows.h> # include <windows.h>
# define zstrerror() gz_strwinerror((DWORD)GetLastError()) # define zstrerror() gz_strwinerror((DWORD)GetLastError())
#else #else
# ifdef STDC # ifndef NO_STRERROR
# include <errno.h> # include <errno.h>
# define zstrerror() strerror(errno) # define zstrerror() strerror(errno)
# else # else

View file

@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files /* gzlib.c -- zlib functions common to reading and writing gzip files
* Copyright (C) 2004, 2010, 2011 Mark Adler * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -17,7 +17,7 @@
/* Local functions */ /* Local functions */
local void gz_reset OF((gz_statep)); local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const char *, int, const char *)); local gzFile gz_open OF((const void *, int, const char *));
#if defined UNDER_CE #if defined UNDER_CE
@ -89,11 +89,19 @@ local void gz_reset(state)
/* Open a gzip file either by name or file descriptor. */ /* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(path, fd, mode) local gzFile gz_open(path, fd, mode)
const char *path; const void *path;
int fd; int fd;
const char *mode; const char *mode;
{ {
gz_statep state; gz_statep state;
size_t len;
int oflag;
#ifdef O_CLOEXEC
int cloexec = 0;
#endif
#ifdef O_EXCL
int exclusive = 0;
#endif
/* check input */ /* check input */
if (path == NULL) if (path == NULL)
@ -133,6 +141,16 @@ local gzFile gz_open(path, fd, mode)
return NULL; return NULL;
case 'b': /* ignore -- will request binary anyway */ case 'b': /* ignore -- will request binary anyway */
break; break;
#ifdef O_CLOEXEC
case 'e':
cloexec = 1;
break;
#endif
#ifdef O_EXCL
case 'x':
exclusive = 1;
break;
#endif
case 'f': case 'f':
state->strategy = Z_FILTERED; state->strategy = Z_FILTERED;
break; break;
@ -168,29 +186,57 @@ local gzFile gz_open(path, fd, mode)
} }
/* save the path name for error messages */ /* save the path name for error messages */
state->path = malloc(strlen(path) + 1); #ifdef _WIN32
if (fd == -2) {
len = wcstombs(NULL, path, 0);
if (len == (size_t)-1)
len = 0;
}
else
#endif
len = strlen(path);
state->path = malloc(len + 1);
if (state->path == NULL) { if (state->path == NULL) {
free(state); free(state);
return NULL; return NULL;
} }
strcpy(state->path, path); #ifdef _WIN32
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
else
*(state->path) = 0;
else
#endif
strcpy(state->path, path);
/* open the file with the appropriate mode (or just use fd) */ /* compute the flags for open() */
state->fd = fd != -1 ? fd : oflag =
open(path,
#ifdef O_LARGEFILE #ifdef O_LARGEFILE
O_LARGEFILE | O_LARGEFILE |
#endif #endif
#ifdef O_BINARY #ifdef O_BINARY
O_BINARY | O_BINARY |
#endif #endif
(state->mode == GZ_READ ? #ifdef O_CLOEXEC
O_RDONLY : (cloexec ? O_CLOEXEC : 0) |
(O_WRONLY | O_CREAT | ( #endif
state->mode == GZ_WRITE ? (state->mode == GZ_READ ?
O_TRUNC : O_RDONLY :
O_APPEND))), (O_WRONLY | O_CREAT |
0666); #ifdef O_EXCL
(exclusive ? O_EXCL : 0) |
#endif
(state->mode == GZ_WRITE ?
O_TRUNC :
O_APPEND)));
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
#ifdef _WIN32
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open(path, oflag, 0666));
if (state->fd == -1) { if (state->fd == -1) {
free(state->path); free(state->path);
free(state); free(state);
@ -244,6 +290,16 @@ gzFile ZEXPORT gzdopen(fd, mode)
return gz; return gz;
} }
/* -- see zlib.h -- */
#ifdef _WIN32
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;
{
return gz_open(path, -2, mode);
}
#endif
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzbuffer(file, size) int ZEXPORT gzbuffer(file, size)
gzFile file; gzFile file;

View file

@ -1,5 +1,5 @@
/* gzread.c -- zlib functions for reading gzip files /* gzread.c -- zlib functions for reading gzip files
* Copyright (C) 2004, 2005, 2010, 2011 Mark Adler * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -57,8 +57,13 @@ local int gz_avail(state)
if (state->err != Z_OK && state->err != Z_BUF_ERROR) if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1; return -1;
if (state->eof == 0) { if (state->eof == 0) {
if (strm->avail_in) if (strm->avail_in) { /* copy what's there to the start */
memmove(state->in, strm->next_in, strm->avail_in); unsigned char *p = state->in, *q = strm->next_in;
unsigned n = strm->avail_in;
do {
*p++ = *q++;
} while (--n);
}
if (gz_load(state, state->in + strm->avail_in, if (gz_load(state, state->in + strm->avail_in,
state->size - strm->avail_in, &got) == -1) state->size - strm->avail_in, &got) == -1)
return -1; return -1;
@ -340,7 +345,7 @@ int ZEXPORT gzread(file, buf, len)
/* get more output, looking for header if required */ /* get more output, looking for header if required */
if (gz_fetch(state) == -1) if (gz_fetch(state) == -1)
return -1; return -1;
continue; /* no progress yet -- go back to memcpy() above */ continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the /* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */ output buffer, allowing at least one gzungetc() to succeed */
} }
@ -373,7 +378,8 @@ int ZEXPORT gzread(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzgetc_(file) #undef gzgetc
int ZEXPORT gzgetc(file)
gzFile file; gzFile file;
{ {
int ret; int ret;
@ -402,12 +408,11 @@ int ZEXPORT gzgetc_(file)
return ret < 1 ? -1 : buf[0]; return ret < 1 ? -1 : buf[0];
} }
#undef gzgetc int ZEXPORT gzgetc_(file)
int ZEXPORT gzgetc(file)
gzFile file; gzFile file;
{ {
return gzgetc_(file); return gzgetc(file);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzungetc(c, file) int ZEXPORT gzungetc(c, file)

View file

@ -338,19 +338,19 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
va_start(va, format); va_start(va, format);
#ifdef NO_vsnprintf #ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void # ifdef HAS_vsprintf_void
(void)vsprintf(state->in, format, va); (void)vsprintf((char *)(state->in), format, va);
va_end(va); va_end(va);
for (len = 0; len < size; len++) for (len = 0; len < size; len++)
if (state->in[len] == 0) break; if (state->in[len] == 0) break;
# else # else
len = vsprintf(state->in, format, va); len = vsprintf((char *)(state->in), format, va);
va_end(va); va_end(va);
# endif # endif
#else #else
# ifdef HAS_vsnprintf_void # ifdef HAS_vsnprintf_void
(void)vsnprintf(state->in, size, format, va); (void)vsnprintf((char *)(state->in), size, format, va);
va_end(va); va_end(va);
len = strlen(state->in); len = strlen((char *)(state->in));
# else # else
len = vsnprintf((char *)(state->in), size, format, va); len = vsnprintf((char *)(state->in), size, format, va);
va_end(va); va_end(va);
@ -416,22 +416,23 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
state->in[size - 1] = 0; state->in[size - 1] = 0;
#ifdef NO_snprintf #ifdef NO_snprintf
# ifdef HAS_sprintf_void # ifdef HAS_sprintf_void
sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
for (len = 0; len < size; len++) for (len = 0; len < size; len++)
if (state->in[len] == 0) break; if (state->in[len] == 0) break;
# else # else
len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif # endif
#else #else
# ifdef HAS_snprintf_void # ifdef HAS_snprintf_void
snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
len = strlen(state->in); len = strlen((char *)(state->in));
# else # else
len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
a19, a20);
# endif # endif
#endif #endif
@ -546,13 +547,15 @@ int ZEXPORT gzclose_w(file)
} }
/* flush, free memory, and close file */ /* flush, free memory, and close file */
if (gz_comp(state, Z_FINISH) == -1) if (state->size) {
ret = state->err; if (gz_comp(state, Z_FINISH) == -1)
if (!state->direct) { ret = state->err;
(void)deflateEnd(&(state->strm)); if (!state->direct) {
free(state->out); (void)deflateEnd(&(state->strm));
free(state->out);
}
free(state->in);
} }
free(state->in);
gz_error(state, Z_OK, NULL); gz_error(state, Z_OK, NULL);
free(state->path); free(state->path);
if (close(state->fd) == -1) if (close(state->fd) == -1)
@ -560,34 +563,3 @@ int ZEXPORT gzclose_w(file)
free(state); free(state);
return ret; return ret;
} }
/* used by zlibVersion() to get the vsnprintf story from the horse's mouth */
unsigned long ZEXPORT gzflags()
{
unsigned long flags = 0;
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifdef NO_vsnprintf
flags += 1L << 25;
# ifdef HAS_vsprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
flags += 1L << 26;
# endif
# endif
#else
flags += 1L << 24;
# ifdef NO_snprintf
flags += 1L << 25;
# ifdef HAS_sprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
flags += 1L << 26;
# endif
# endif
#endif
return flags;
}

View file

@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression /* inflate.c -- zlib decompression
* Copyright (C) 1995-2011 Mark Adler * Copyright (C) 1995-2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -519,11 +519,6 @@ unsigned out;
bits -= bits & 7; \ bits -= bits & 7; \
} while (0) } while (0)
/* Reverse the bytes in a 32-bit value */
#define REVERSE(q) \
((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
/* /*
inflate() uses a state machine to process as much input data and generate as inflate() uses a state machine to process as much input data and generate as
much output data as possible before returning. The state machine is much output data as possible before returning. The state machine is
@ -817,7 +812,7 @@ int flush;
#endif #endif
case DICTID: case DICTID:
NEEDBITS(32); NEEDBITS(32);
strm->adler = state->check = REVERSE(hold); strm->adler = state->check = ZSWAP32(hold);
INITBITS(); INITBITS();
state->mode = DICT; state->mode = DICT;
case DICT: case DICT:
@ -1189,7 +1184,7 @@ int flush;
#ifdef GUNZIP #ifdef GUNZIP
state->flags ? hold : state->flags ? hold :
#endif #endif
REVERSE(hold)) != state->check) { ZSWAP32(hold)) != state->check) {
strm->msg = (char *)"incorrect data check"; strm->msg = (char *)"incorrect data check";
state->mode = BAD; state->mode = BAD;
break; break;
@ -1275,7 +1270,7 @@ const Bytef *dictionary;
uInt dictLength; uInt dictLength;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned long id; unsigned long dictid;
unsigned char *next; unsigned char *next;
unsigned avail; unsigned avail;
int ret; int ret;
@ -1286,11 +1281,11 @@ uInt dictLength;
if (state->wrap != 0 && state->mode != DICT) if (state->wrap != 0 && state->mode != DICT)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
/* check for correct dictionary id */ /* check for correct dictionary identifier */
if (state->mode == DICT) { if (state->mode == DICT) {
id = adler32(0L, Z_NULL, 0); dictid = adler32(0L, Z_NULL, 0);
id = adler32(id, dictionary, dictLength); dictid = adler32(dictid, dictionary, dictLength);
if (id != state->check) if (dictid != state->check)
return Z_DATA_ERROR; return Z_DATA_ERROR;
} }

View file

@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.2.6 Copyright 1995-2012 Mark Adler "; " inflate 1.2.7 Copyright 1995-2012 Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 69}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

View file

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2011 Jean-loup Gailly. * Copyright (C) 1995-2012 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -65,7 +65,6 @@
# define gzdopen z_gzdopen # define gzdopen z_gzdopen
# define gzeof z_gzeof # define gzeof z_gzeof
# define gzerror z_gzerror # define gzerror z_gzerror
# define gzflags z_gzflags
# define gzflush z_gzflush # define gzflush z_gzflush
# define gzgetc z_gzgetc # define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_ # define gzgetc_ z_gzgetc_
@ -74,6 +73,9 @@
# define gzoffset64 z_gzoffset64 # define gzoffset64 z_gzoffset64
# define gzopen z_gzopen # define gzopen z_gzopen
# define gzopen64 z_gzopen64 # define gzopen64 z_gzopen64
# ifdef _WIN32
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf # define gzprintf z_gzprintf
# define gzputc z_gzputc # define gzputc z_gzputc
# define gzputs z_gzputs # define gzputs z_gzputs
@ -127,9 +129,9 @@
# define free_func z_free_func # define free_func z_free_func
# ifndef Z_SOLO # ifndef Z_SOLO
# define gzFile z_gzFile # define gzFile z_gzFile
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# endif # endif
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func # define in_func z_in_func
# define intf z_intf # define intf z_intf
# define out_func z_out_func # define out_func z_out_func
@ -142,9 +144,7 @@
# define voidpf z_voidpf # define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */ /* all zlib structs in zlib.h and zconf.h */
# ifndef Z_SOLO # define gz_header_s z_gz_header_s
# define gz_header_s z_gz_header_s
# endif
# define internal_state z_internal_state # define internal_state z_internal_state
#endif #endif
@ -388,6 +388,29 @@ typedef uLong FAR uLongf;
typedef Byte *voidp; typedef Byte *voidp;
#endif #endif
/* ./configure may #define Z_U4 here */
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# else
# if (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# else
# if (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
# endif
# endif
#endif
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
#endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H # define Z_HAVE_UNISTD_H
#endif #endif
@ -402,28 +425,45 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifdef _WIN32
# include <stddef.h> /* for wchar_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering * though the former does not conform to the LFS document), but considering
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations * equivalently requesting no 64-bit operations
*/ */
#if -_LARGEFILE64_SOURCE - -1 == 1 #if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE # undef _LARGEFILE64_SOURCE
#endif #endif
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
# define Z_LARGE # define Z_HAVE_UNISTD_H
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
# endif
# endif
#endif #endif
#if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO) #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# include <unistd.h> /* for SEEK_* and off_t */ # define Z_LFS64
# ifdef VMS #endif
# include <unixio.h> /* for off_t */
# endif #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# ifndef z_off_t # define Z_LARGE64
# define z_off_t off_t #endif
# endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
# define Z_WANT64
#endif #endif
#if !defined(SEEK_SET) && !defined(Z_SOLO) #if !defined(SEEK_SET) && !defined(Z_SOLO)
@ -436,14 +476,14 @@ typedef uLong FAR uLongf;
# define z_off_t long # define z_off_t long
#endif #endif
#if !defined(_WIN32) && (defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0) #if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t # define z_off64_t off64_t
#else #else
# if defined(_WIN32) # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
# define z_off64_t __int64 # define z_off64_t __int64
# else # else
# define z_off64_t z_off_t # define z_off64_t z_off_t
#endif # endif
#endif #endif
/* MVS linker does not support external names larger than 8 bytes */ /* MVS linker does not support external names larger than 8 bytes */

View file

@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library /* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.6, January 29th, 2012 version 1.2.7, May 2nd, 2012
Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
@ -37,11 +37,11 @@
extern "C" { extern "C" {
#endif #endif
#define ZLIB_VERSION "1.2.6" #define ZLIB_VERSION "1.2.7"
#define ZLIB_VERNUM 0x1260 #define ZLIB_VERNUM 0x1270
#define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2 #define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 6 #define ZLIB_VER_REVISION 7
#define ZLIB_VER_SUBREVISION 0 #define ZLIB_VER_SUBREVISION 0
/* /*
@ -452,14 +452,17 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
error. However if all decompression is to be performed in a single step (a error. However if all decompression is to be performed in a single step (a
single call of inflate), the parameter flush should be set to Z_FINISH. In single call of inflate), the parameter flush should be set to Z_FINISH. In
this case all pending input is processed and all pending output is flushed; this case all pending input is processed and all pending output is flushed;
avail_out must be large enough to hold all the uncompressed data. (The size avail_out must be large enough to hold all of the uncompressed data for the
of the uncompressed data may have been saved by the compressor for this operation to complete. (The size of the uncompressed data may have been
purpose.) The next operation on this stream must be inflateEnd to deallocate saved by the compressor for this purpose.) The use of Z_FINISH is not
the decompression state. The use of Z_FINISH is not required to perform an required to perform an inflation in one step. However it may be used to
inflation in one step. However it may be used to inform inflate that a inform inflate that a faster approach can be used for the single inflate()
faster approach can be used for the single inflate() call. Z_FINISH also call. Z_FINISH also informs inflate to not maintain a sliding window if the
informs inflate to not maintain a sliding window if the stream completes, stream completes, which reduces inflate's memory footprint. If the stream
which reduces inflate's memory footprint. does not complete, either because not all of the stream is provided or not
enough output space is provided, then a sliding window will be allocated and
inflate() can be called again to continue the operation as if Z_NO_FLUSH had
been used.
In this implementation, inflate() always flushes as much output as In this implementation, inflate() always flushes as much output as
possible to the output buffer, and always uses the faster approach on the possible to the output buffer, and always uses the faster approach on the
@ -1217,7 +1220,10 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
"a" can be used instead of "w" to request that the gzip stream that will "a" can be used instead of "w" to request that the gzip stream that will
be written be appended to the file. "+" will result in an error, since be written be appended to the file. "+" will result in an error, since
reading and writing to the same gzip file is not supported. reading and writing to the same gzip file is not supported. The addition of
"x" when writing will create the file exclusively, which fails if the file
already exists. On systems that support it, the addition of "e" when
reading or writing will set the flag to close the file on an execve() call.
These functions, as well as gzip, will read and decode a sequence of gzip These functions, as well as gzip, will read and decode a sequence of gzip
streams in a file. The append function of gzopen() can be used to create streams in a file. The append function of gzopen() can be used to create
@ -1578,9 +1584,8 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/* /*
Update a running CRC-32 with the bytes buf[0..len-1] and return the Update a running CRC-32 with the bytes buf[0..len-1] and return the
updated CRC-32. If buf is Z_NULL, this function returns the required updated CRC-32. If buf is Z_NULL, this function returns the required
initial value for the for the crc. Pre- and post-conditioning (one's initial value for the crc. Pre- and post-conditioning (one's complement) is
complement) is performed within this function so it shouldn't be done by the performed within this function so it shouldn't be done by the application.
application.
Usage example: Usage example:
@ -1650,9 +1655,15 @@ struct gzFile_s {
unsigned char *next; unsigned char *next;
z_off64_t pos; z_off64_t pos;
}; };
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#define gzgetc(g) \ #ifdef Z_PREFIX_SET
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g)) # undef z_gzgetc
# define z_gzgetc(g) \
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
#else
# define gzgetc(g) \
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
#endif
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
@ -1660,7 +1671,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
* functions are changed to 64 bits) -- in case these are set on systems * functions are changed to 64 bits) -- in case these are set on systems
* without large file support, _LFS64_LARGEFILE must also be true * without large file support, _LFS64_LARGEFILE must also be true
*/ */
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 #ifdef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
@ -1669,7 +1680,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
#endif #endif
#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
# ifdef Z_PREFIX_SET # ifdef Z_PREFIX_SET
# define z_gzopen z_gzopen64 # define z_gzopen z_gzopen64
# define z_gzseek z_gzseek64 # define z_gzseek z_gzseek64
@ -1685,7 +1696,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
# define adler32_combine adler32_combine64 # define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64 # define crc32_combine crc32_combine64
# endif # endif
# ifndef _LARGEFILE64_SOURCE # ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
@ -1717,12 +1728,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
/* undocumented functions */ /* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#ifndef Z_SOLO #if defined(_WIN32) && !defined(Z_SOLO)
ZEXTERN unsigned long ZEXPORT gzflags OF((void)); ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1,11 +1,14 @@
/* zutil.c -- target dependent utility functions for the compression library /* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-2005, 2010, 2011 Jean-loup Gailly. * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zutil.h" #include "zutil.h"
#ifndef Z_SOLO
# include "gzguts.h"
#endif
#ifndef NO_DUMMY_DECL #ifndef NO_DUMMY_DECL
struct internal_state {int dummy;}; /* for buggy compilers */ struct internal_state {int dummy;}; /* for buggy compilers */
@ -85,11 +88,31 @@ uLong ZEXPORT zlibCompileFlags()
#ifdef FASTEST #ifdef FASTEST
flags += 1L << 21; flags += 1L << 21;
#endif #endif
#ifdef Z_SOLO #if defined(STDC) || defined(Z_HAVE_STDARG_H)
return flags; # ifdef NO_vsnprintf
flags += 1L << 25;
# ifdef HAS_vsprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
flags += 1L << 26;
# endif
# endif
#else #else
return flags + gzflags(); flags += 1L << 24;
# ifdef NO_snprintf
flags += 1L << 25;
# ifdef HAS_sprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
flags += 1L << 26;
# endif
# endif
#endif #endif
return flags;
} }
#ifdef DEBUG #ifdef DEBUG

View file

@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library /* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2011 Jean-loup Gailly. * Copyright (C) 1995-2012 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -13,7 +13,7 @@
#ifndef ZUTIL_H #ifndef ZUTIL_H
#define ZUTIL_H #define ZUTIL_H
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) #ifdef HAVE_HIDDEN
# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else #else
# define ZLIB_INTERNAL # define ZLIB_INTERNAL
@ -245,4 +245,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#endif /* ZUTIL_H */ #endif /* ZUTIL_H */