Commit 13e02608 authored by Alexandre Julliard's avatar Alexandre Julliard

zlib: Import upstream release 1.3.

parent 673cac9e
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "zutil.h" #include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#define BASE 65521U /* largest prime smaller than 65536 */ #define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552 #define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
...@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); ...@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#endif #endif
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32_z( uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
uLong adler,
const Bytef *buf,
z_size_t len)
{
unsigned long sum2; unsigned long sum2;
unsigned n; unsigned n;
...@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z( ...@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(
} }
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32( uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
uLong adler,
const Bytef *buf,
uInt len)
{
return adler32_z(adler, buf, len); return adler32_z(adler, buf, len);
} }
/* ========================================================================= */ /* ========================================================================= */
local uLong adler32_combine_( local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
uLong adler1,
uLong adler2,
z_off64_t len2)
{
unsigned long sum1; unsigned long sum1;
unsigned long sum2; unsigned long sum2;
unsigned rem; unsigned rem;
...@@ -169,18 +155,10 @@ local uLong adler32_combine_( ...@@ -169,18 +155,10 @@ local uLong adler32_combine_(
} }
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32_combine( uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
uLong adler1,
uLong adler2,
z_off_t len2)
{
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
} }
uLong ZEXPORT adler32_combine64( uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
uLong adler1,
uLong adler2,
z_off64_t len2)
{
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
} }
...@@ -291,14 +291,14 @@ typedef struct internal_state { ...@@ -291,14 +291,14 @@ typedef struct internal_state {
memory checker errors from longest match routines */ memory checker errors from longest match routines */
/* in trees.c */ /* in trees.c */
void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); void ZLIB_INTERNAL _tr_init(deflate_state *s);
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
ulg stored_len, int last)); ulg stored_len, int last);
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); void ZLIB_INTERNAL _tr_align(deflate_state *s);
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
ulg stored_len, int last)); ulg stored_len, int last);
#define d_code(dist) \ #define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
......
...@@ -47,10 +47,7 @@ ...@@ -47,10 +47,7 @@
requires strm->avail_out >= 258 for each loop to avoid checking for requires strm->avail_out >= 258 for each loop to avoid checking for
output space. output space.
*/ */
void ZLIB_INTERNAL inflate_fast( void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
z_streamp strm,
unsigned start)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *in; /* local strm->next_in */
z_const unsigned char FAR *last; /* have enough input while in < last */ z_const unsigned char FAR *last; /* have enough input while in < last */
......
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
...@@ -91,20 +91,7 @@ ...@@ -91,20 +91,7 @@
# endif # endif
#endif #endif
/* function prototypes */ local int inflateStateCheck(z_streamp strm) {
local int inflateStateCheck OF((z_streamp strm));
local void fixedtables OF((struct inflate_state FAR *state));
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
unsigned copy));
#ifdef BUILDFIXED
void makefixed OF((void));
#endif
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
unsigned len));
local int inflateStateCheck(
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (strm == Z_NULL || if (strm == Z_NULL ||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
...@@ -116,9 +103,7 @@ local int inflateStateCheck( ...@@ -116,9 +103,7 @@ local int inflateStateCheck(
return 0; return 0;
} }
int ZEXPORT inflateResetKeep( int ZEXPORT inflateResetKeep(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
...@@ -142,9 +127,7 @@ int ZEXPORT inflateResetKeep( ...@@ -142,9 +127,7 @@ int ZEXPORT inflateResetKeep(
return Z_OK; return Z_OK;
} }
int ZEXPORT inflateReset( int ZEXPORT inflateReset(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
...@@ -155,10 +138,7 @@ int ZEXPORT inflateReset( ...@@ -155,10 +138,7 @@ int ZEXPORT inflateReset(
return inflateResetKeep(strm); return inflateResetKeep(strm);
} }
int ZEXPORT inflateReset2( int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
z_streamp strm,
int windowBits)
{
int wrap; int wrap;
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -195,12 +175,8 @@ int ZEXPORT inflateReset2( ...@@ -195,12 +175,8 @@ int ZEXPORT inflateReset2(
return inflateReset(strm); return inflateReset(strm);
} }
int ZEXPORT inflateInit2_( int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
z_streamp strm, const char *version, int stream_size) {
int windowBits,
const char *version,
int stream_size)
{
int ret; int ret;
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -239,22 +215,17 @@ int ZEXPORT inflateInit2_( ...@@ -239,22 +215,17 @@ int ZEXPORT inflateInit2_(
return ret; return ret;
} }
int ZEXPORT inflateInit_( int ZEXPORT inflateInit_(z_streamp strm, const char *version,
z_streamp strm, int stream_size) {
const char *version,
int stream_size)
{
return inflateInit2_(strm, DEF_WBITS, version, stream_size); return inflateInit2_(strm, DEF_WBITS, version, stream_size);
} }
int ZEXPORT inflatePrime( int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
z_streamp strm,
int bits,
int value)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits == 0)
return Z_OK;
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
if (bits < 0) { if (bits < 0) {
state->hold = 0; state->hold = 0;
...@@ -278,9 +249,7 @@ int ZEXPORT inflatePrime( ...@@ -278,9 +249,7 @@ int ZEXPORT inflatePrime(
used for threaded applications, since the rewriting of the tables and virgin used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe. may not be thread-safe.
*/ */
local void fixedtables( local void fixedtables(struct inflate_state FAR *state) {
struct inflate_state FAR *state)
{
#ifdef BUILDFIXED #ifdef BUILDFIXED
static int virgin = 1; static int virgin = 1;
static code *lenfix, *distfix; static code *lenfix, *distfix;
...@@ -342,7 +311,7 @@ local void fixedtables( ...@@ -342,7 +311,7 @@ local void fixedtables(
a.out > inffixed.h a.out > inffixed.h
*/ */
void makefixed() void makefixed(void)
{ {
unsigned low, size; unsigned low, size;
struct inflate_state state; struct inflate_state state;
...@@ -396,11 +365,7 @@ void makefixed() ...@@ -396,11 +365,7 @@ void makefixed()
output will fall in the output data, making match copies simpler and faster. output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches. The advantage may be dependent on the size of the processor's data caches.
*/ */
local int updatewindow( local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
z_streamp strm,
const Bytef *end,
unsigned copy)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned dist; unsigned dist;
...@@ -622,10 +587,7 @@ local int updatewindow( ...@@ -622,10 +587,7 @@ local int updatewindow(
will return Z_BUF_ERROR if it has not reached the end of the stream. will return Z_BUF_ERROR if it has not reached the end of the stream.
*/ */
int ZEXPORT inflate( int ZEXPORT inflate(z_streamp strm, int flush) {
z_streamp strm,
int flush)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
...@@ -1301,9 +1263,7 @@ int ZEXPORT inflate( ...@@ -1301,9 +1263,7 @@ int ZEXPORT inflate(
return ret; return ret;
} }
int ZEXPORT inflateEnd( int ZEXPORT inflateEnd(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
...@@ -1315,11 +1275,8 @@ int ZEXPORT inflateEnd( ...@@ -1315,11 +1275,8 @@ int ZEXPORT inflateEnd(
return Z_OK; return Z_OK;
} }
int ZEXPORT inflateGetDictionary( int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
z_streamp strm, uInt *dictLength) {
Bytef *dictionary,
uInt *dictLength)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
/* check state */ /* check state */
...@@ -1338,11 +1295,8 @@ int ZEXPORT inflateGetDictionary( ...@@ -1338,11 +1295,8 @@ int ZEXPORT inflateGetDictionary(
return Z_OK; return Z_OK;
} }
int ZEXPORT inflateSetDictionary( int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
z_streamp strm, uInt dictLength) {
const Bytef *dictionary,
uInt dictLength)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned long dictid; unsigned long dictid;
int ret; int ret;
...@@ -1373,10 +1327,7 @@ int ZEXPORT inflateSetDictionary( ...@@ -1373,10 +1327,7 @@ int ZEXPORT inflateSetDictionary(
return Z_OK; return Z_OK;
} }
int ZEXPORT inflateGetHeader( int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
z_streamp strm,
gz_headerp head)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
/* check state */ /* check state */
...@@ -1401,11 +1352,8 @@ int ZEXPORT inflateGetHeader( ...@@ -1401,11 +1352,8 @@ int ZEXPORT inflateGetHeader(
called again with more data and the *have state. *have is initialized to called again with more data and the *have state. *have is initialized to
zero for the first call. zero for the first call.
*/ */
local unsigned syncsearch( local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
unsigned FAR *have, unsigned len) {
const unsigned char FAR *buf,
unsigned len)
{
unsigned got; unsigned got;
unsigned next; unsigned next;
...@@ -1424,9 +1372,7 @@ local unsigned syncsearch( ...@@ -1424,9 +1372,7 @@ local unsigned syncsearch(
return next; return next;
} }
int ZEXPORT inflateSync( int ZEXPORT inflateSync(z_streamp strm) {
z_streamp strm)
{
unsigned len; /* number of bytes to look at or looked at */ unsigned len; /* number of bytes to look at or looked at */
int flags; /* temporary to save header status */ int flags; /* temporary to save header status */
unsigned long in, out; /* temporary to save total_in and total_out */ unsigned long in, out; /* temporary to save total_in and total_out */
...@@ -1482,9 +1428,7 @@ int ZEXPORT inflateSync( ...@@ -1482,9 +1428,7 @@ int ZEXPORT inflateSync(
block. When decompressing, PPP checks that at the end of input packet, block. When decompressing, PPP checks that at the end of input packet,
inflate is waiting for these length bytes. inflate is waiting for these length bytes.
*/ */
int ZEXPORT inflateSyncPoint( int ZEXPORT inflateSyncPoint(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
...@@ -1492,10 +1436,7 @@ int ZEXPORT inflateSyncPoint( ...@@ -1492,10 +1436,7 @@ int ZEXPORT inflateSyncPoint(
return state->mode == STORED && state->bits == 0; return state->mode == STORED && state->bits == 0;
} }
int ZEXPORT inflateCopy( int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
z_streamp dest,
z_streamp source)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
struct inflate_state FAR *copy; struct inflate_state FAR *copy;
unsigned char FAR *window; unsigned char FAR *window;
...@@ -1539,10 +1480,7 @@ int ZEXPORT inflateCopy( ...@@ -1539,10 +1480,7 @@ int ZEXPORT inflateCopy(
return Z_OK; return Z_OK;
} }
int ZEXPORT inflateUndermine( int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
z_streamp strm,
int subvert)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
...@@ -1557,10 +1495,7 @@ int ZEXPORT inflateUndermine( ...@@ -1557,10 +1495,7 @@ int ZEXPORT inflateUndermine(
#endif #endif
} }
int ZEXPORT inflateValidate( int ZEXPORT inflateValidate(z_streamp strm, int check) {
z_streamp strm,
int check)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
...@@ -1572,9 +1507,7 @@ int ZEXPORT inflateValidate( ...@@ -1572,9 +1507,7 @@ int ZEXPORT inflateValidate(
return Z_OK; return Z_OK;
} }
long ZEXPORT inflateMark( long ZEXPORT inflateMark(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
...@@ -1585,9 +1518,7 @@ long ZEXPORT inflateMark( ...@@ -1585,9 +1518,7 @@ long ZEXPORT inflateMark(
(state->mode == MATCH ? state->was - state->length : 0)); (state->mode == MATCH ? state->was - state->length : 0));
} }
unsigned long ZEXPORT inflateCodesUsed( unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
z_streamp strm)
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return (unsigned long)-1; if (inflateStateCheck(strm)) return (unsigned long)-1;
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
......
/* inftrees.c -- generate Huffman trees for efficient decoding /* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2022 Mark Adler * Copyright (C) 1995-2023 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
*/ */
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.2.13 Copyright 1995-2022 Mark Adler "; " inflate 1.3 Copyright 1995-2023 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
...@@ -29,14 +29,9 @@ const char inflate_copyright[] = ...@@ -29,14 +29,9 @@ const char inflate_copyright[] =
table index bits. It will differ if the request is greater than the table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code. longest code or if it is less than the shortest code.
*/ */
int ZLIB_INTERNAL inflate_table( int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
codetype type, unsigned codes, code FAR * FAR *table,
unsigned short FAR *lens, unsigned FAR *bits, unsigned short FAR *work) {
unsigned codes,
code FAR * FAR *table,
unsigned FAR *bits,
unsigned short FAR *work)
{
unsigned len; /* a code's length in bits */ unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */ unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */ unsigned min, max; /* minimum and maximum code lengths */
...@@ -62,7 +57,7 @@ int ZLIB_INTERNAL inflate_table( ...@@ -62,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(
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, 194, 65}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
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,
......
...@@ -57,6 +57,6 @@ typedef enum { ...@@ -57,6 +57,6 @@ typedef enum {
DISTS DISTS
} codetype; } codetype;
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table, unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work)); unsigned FAR *bits, unsigned short FAR *work);
...@@ -241,7 +241,11 @@ ...@@ -241,7 +241,11 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef unsigned long z_size_t; # ifdef _WIN64
typedef unsigned long long z_size_t;
# else
typedef unsigned long z_size_t;
# endif
#else #else
# define z_longlong long long # define z_longlong long long
# if defined(NO_SIZE_T) # if defined(NO_SIZE_T)
...@@ -520,7 +524,7 @@ typedef uLong FAR uLongf; ...@@ -520,7 +524,7 @@ typedef uLong FAR uLongf;
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t # define z_off64_t off64_t
#else #else
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) # if defined(_WIN32) && !defined(__GNUC__)
# 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
......
...@@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { ...@@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = {
}; };
const char * ZEXPORT zlibVersion() const char * ZEXPORT zlibVersion(void) {
{
return ZLIB_VERSION; return ZLIB_VERSION;
} }
uLong ZEXPORT zlibCompileFlags() uLong ZEXPORT zlibCompileFlags(void) {
{
uLong flags; uLong flags;
flags = 0; flags = 0;
...@@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() ...@@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags()
# endif # endif
int ZLIB_INTERNAL z_verbose = verbose; int ZLIB_INTERNAL z_verbose = verbose;
void ZLIB_INTERNAL z_error( void ZLIB_INTERNAL z_error(char *m) {
char *m)
{
fprintf(stderr, "%s\n", m); fprintf(stderr, "%s\n", m);
exit(1); exit(1);
} }
...@@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error( ...@@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error(
/* exported to allow conversion of error code to string for compress() and /* exported to allow conversion of error code to string for compress() and
* uncompress() * uncompress()
*/ */
const char * ZEXPORT zError( const char * ZEXPORT zError(int err) {
int err)
{
return ERR_MSG(err); return ERR_MSG(err);
} }
...@@ -148,22 +142,14 @@ const char * ZEXPORT zError( ...@@ -148,22 +142,14 @@ const char * ZEXPORT zError(
#ifndef HAVE_MEMCPY #ifndef HAVE_MEMCPY
void ZLIB_INTERNAL zmemcpy( void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
Bytef* dest,
const Bytef* source,
uInt len)
{
if (len == 0) return; if (len == 0) return;
do { do {
*dest++ = *source++; /* ??? to be unrolled */ *dest++ = *source++; /* ??? to be unrolled */
} while (--len != 0); } while (--len != 0);
} }
int ZLIB_INTERNAL zmemcmp( int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
const Bytef* s1,
const Bytef* s2,
uInt len)
{
uInt j; uInt j;
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
...@@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp( ...@@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(
return 0; return 0;
} }
void ZLIB_INTERNAL zmemzero( void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
Bytef* dest,
uInt len)
{
if (len == 0) return; if (len == 0) return;
do { do {
*dest++ = 0; /* ??? to be unrolled */ *dest++ = 0; /* ??? to be unrolled */
...@@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR]; ...@@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR];
* a protected system like OS/2. Use Microsoft C instead. * a protected system like OS/2. Use Microsoft C instead.
*/ */
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
{
voidpf buf; voidpf buf;
ulg bsize = (ulg)items*size; ulg bsize = (ulg)items*size;
...@@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) ...@@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
return buf; return buf;
} }
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
{
int n; int n;
(void)opaque; (void)opaque;
...@@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) ...@@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
# define _hfree hfree # define _hfree hfree
#endif #endif
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
{
(void)opaque; (void)opaque;
return _halloc((long)items, size); return _halloc((long)items, size);
} }
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
{
(void)opaque; (void)opaque;
_hfree(ptr); _hfree(ptr);
} }
...@@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) ...@@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
#ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */
#ifndef STDC #ifndef STDC
extern voidp malloc OF((uInt size)); extern voidp malloc(uInt size);
extern voidp calloc OF((uInt items, uInt size)); extern voidp calloc(uInt items, uInt size);
extern void free OF((voidpf ptr)); extern void free(voidpf ptr);
#endif #endif
voidpf ZLIB_INTERNAL zcalloc( voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
voidpf opaque,
unsigned items,
unsigned size)
{
(void)opaque; (void)opaque;
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size); (voidpf)calloc(items, size);
} }
void ZLIB_INTERNAL zcfree( void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
voidpf opaque,
voidpf ptr)
{
(void)opaque; (void)opaque;
free(ptr); free(ptr);
} }
......
...@@ -191,9 +191,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -191,9 +191,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* provide prototypes for these when building zlib without LFS */ /* provide prototypes for these when building zlib without LFS */
#if !defined(_WIN32) && \ #if !defined(_WIN32) && \
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
#endif #endif
/* common defaults */ /* common defaults */
...@@ -232,16 +232,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -232,16 +232,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len) # define zmemzero(dest, len) memset(dest, 0, len)
# endif # endif
#else #else
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
#endif #endif
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
# include <stdio.h> # include <stdio.h>
extern int ZLIB_INTERNAL z_verbose; extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m)); extern void ZLIB_INTERNAL z_error(char *m);
# define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;}
...@@ -258,9 +258,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -258,9 +258,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
#ifndef Z_SOLO #ifndef Z_SOLO
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
unsigned size)); unsigned size);
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
#endif #endif
#define ZALLOC(strm, items, size) \ #define ZALLOC(strm, items, size) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment