#endif
/* ========================================================================= */
-uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len) {
+uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint32_t len) {
uint32_t sum2;
unsigned n;
register unsigned n;
register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
+ unsigned int wsize = s->w_size;
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
+ more = (unsigned)(s->window_size -(unsigned long)s->lookahead -(unsigned long)s->strstart);
/* Deal with !@#$% 64K limit: */
if (sizeof(int) <= 2) {
/* Initialize the hash value now that we have some input: */
if (s->lookahead + s->insert >= MIN_MATCH) {
- uInt str = s->strstart - s->insert;
+ unsigned int str = s->strstart - s->insert;
s->ins_h = s->window[str];
if (str >= 1)
UPDATE_HASH(s, s->ins_h, str + 1 - (MIN_MATCH-1));
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
*/
if (s->high_water < s->window_size) {
- ulg curr = s->strstart + (ulg)(s->lookahead);
- ulg init;
+ unsigned long curr = s->strstart + (unsigned long)(s->lookahead);
+ unsigned long init;
if (s->high_water < curr) {
/* Previous high water mark below current data -- zero WIN_INIT
init = WIN_INIT;
memset(s->window + curr, 0, (unsigned)init);
s->high_water = curr + init;
- } else if (s->high_water < (ulg)curr + WIN_INIT) {
+ } else if (s->high_water < (unsigned long)curr + WIN_INIT) {
/* High water mark at or above current data, but below current data
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
* to end of window, whichever is less.
*/
- init = (ulg)curr + WIN_INIT - s->high_water;
+ init = (unsigned long)curr + WIN_INIT - s->high_water;
if (init > s->window_size - s->high_water)
init = s->window_size - s->high_water;
memset(s->window + s->high_water, 0, (unsigned)init);
}
}
- Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search");
+ Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search");
}
#endif
/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005, 2014 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2005, 2014 Jean-loup Gailly, Mark Adler.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
-int ZEXPORT compress2(unsigned char *dest, uLong *destLen, const unsigned char *source,
- uLong sourceLen, int level) {
+int ZEXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source,
+ unsigned long sourceLen, int level) {
z_stream stream;
int err;
- const uInt max = (uInt)0 - 1;
- uLong left;
+ const unsigned int max = (unsigned int)0 - 1;
+ unsigned long left;
left = *destLen;
*destLen = 0;
do {
if (stream.avail_out == 0) {
- stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ stream.avail_out = left > (unsigned long)max ? max : (unsigned int)left;
left -= stream.avail_out;
}
if (stream.avail_in == 0) {
- stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
+ stream.avail_in = sourceLen > (unsigned long)max ? max : (unsigned int)sourceLen;
sourceLen -= stream.avail_in;
}
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
/* ===========================================================================
*/
-int ZEXPORT compress(unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen) {
+int ZEXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen) {
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
+ If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
-uLong ZEXPORT compressBound(uLong sourceLen) {
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
- (sourceLen >> 25) + 13;
+unsigned long ZEXPORT compressBound(unsigned long sourceLen) {
+ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13;
}
#ifdef __MINGW32__
# include <sys/param.h>
-#elif _WIN32
+#elif defined(WIN32) || defined(_WIN32)
# define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321
# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
#include "deflate.h"
#if BYTE_ORDER == LITTLE_ENDIAN
-static uint32_t crc32_little(uint32_t, const unsigned char *, unsigned);
+static uint32_t crc32_little(uint32_t, const unsigned char *, z_off64_t);
#elif BYTE_ORDER == BIG_ENDIAN
-static uint32_t crc32_big(uint32_t, const unsigned char *, unsigned);
+static uint32_t crc32_big(uint32_t, const unsigned char *, z_off64_t);
#endif
/* Local functions for crc concatenation */
#define DO4 DO1; DO1; DO1; DO1
/* ========================================================================= */
-uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, uInt len) {
+uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, z_off64_t len) {
if (buf == Z_NULL) return 0;
#ifdef DYNAMIC_CRC_TABLE
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
-static uint32_t crc32_little(uint32_t crc, const unsigned char *buf, unsigned len) {
+static uint32_t crc32_little(uint32_t crc, const unsigned char *buf, z_off64_t len) {
register uint32_t c;
register const uint32_t *buf4;
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
-static uint32_t crc32_big(uint32_t crc, const unsigned char *buf, unsigned len) {
+static uint32_t crc32_big(uint32_t crc, const unsigned char *buf, z_off64_t len) {
register uint32_t c;
register const uint32_t *buf4;
local block_state deflate_rle (deflate_state *s, int flush);
local block_state deflate_huff (deflate_state *s, int flush);
local void lm_init (deflate_state *s);
-local void putShortMSB (deflate_state *s, uInt b);
-ZLIB_INTERNAL void flush_pending(z_stream *strm);
-ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size);
+local void putShortMSB (deflate_state *s, uint16_t b);
+ZLIB_INTERNAL void flush_pending (z_stream *strm);
+ZLIB_INTERNAL int read_buf (z_stream *strm, unsigned char *buf, unsigned size);
extern void crc_reset(deflate_state *const s);
extern void crc_finalize(deflate_state *const s);
overlay = (uint16_t *) ZALLOC(strm, s->lit_bufsize, sizeof(uint16_t)+2);
s->pending_buf = (unsigned char *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(uint16_t)+2L);
+ s->pending_buf_size = (unsigned long)s->lit_bufsize * (sizeof(uint16_t)+2L);
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
s->pending_buf == Z_NULL) {
}
/* ========================================================================= */
-int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) {
+int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength) {
deflate_state *s;
- uInt str, n;
+ unsigned int str, n;
int wrap;
- unsigned avail;
+ uint32_t avail;
const unsigned char *next;
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
}
/* ========================================================================= */
-int ZEXPORT deflatePending(z_stream *strm, unsigned *pending, int *bits) {
+int ZEXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits) {
if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
if (pending != Z_NULL)
* upper bound of about 14% expansion does not seem onerous for output buffer
* allocation.
*/
-uLong ZEXPORT deflateBound(z_stream *strm, uLong sourceLen) {
+unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen) {
deflate_state *s;
- uLong complen, wraplen;
+ unsigned long complen, wraplen;
unsigned char *str;
/* conservative upper bound for compressed data */
* IN assertion: the stream state is correct and there is enough room in
* pending_buf.
*/
-local void putShortMSB(deflate_state *s, uInt b) {
+local void putShortMSB(deflate_state *s, uint16_t b) {
put_byte(s, (unsigned char)(b >> 8));
put_byte(s, (unsigned char)(b & 0xff));
}
* (See also read_buf()).
*/
ZLIB_INTERNAL void flush_pending(z_stream *strm) {
- unsigned len;
+ uint32_t len;
deflate_state *s = strm->state;
_tr_flush_bits(s);
} else
#endif
{
- uInt header = (Z_DEFLATED + ((s->w_bits-8) << 4)) << 8;
- uInt level_flags;
+ unsigned int header = (Z_DEFLATED + ((s->w_bits-8) << 4)) << 8;
+ unsigned int level_flags;
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
level_flags = 0;
/* Save the adler32 of the preset dictionary: */
if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ putShortMSB(s, (uint16_t)(strm->adler >> 16));
+ putShortMSB(s, (uint16_t)strm->adler);
}
strm->adler = adler32(0L, Z_NULL, 0);
}
#ifdef GZIP
if (s->status == EXTRA_STATE) {
if (s->gzhead->extra != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ uint32_t beg = s->pending; /* start of bytes to update crc */
while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
if (s->pending == s->pending_buf_size) {
}
if (s->status == NAME_STATE) {
if (s->gzhead->name != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ uint32_t beg = s->pending; /* start of bytes to update crc */
int val;
do {
}
if (s->status == COMMENT_STATE) {
if (s->gzhead->comment != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ uint32_t beg = s->pending; /* start of bytes to update crc */
int val;
do {
} else
#endif
{
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ putShortMSB(s, (uint16_t)(strm->adler >> 16));
+ putShortMSB(s, (uint16_t)strm->adler);
}
flush_pending(strm);
/* If avail_out is zero, the application will call deflate again
memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(unsigned char));
memcpy((void *)ds->prev, (void *)ss->prev, ds->w_size * sizeof(Pos));
memcpy((void *)ds->head, (void *)ss->head, ds->hash_size * sizeof(Pos));
- memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
+ memcpy(ds->pending_buf, ss->pending_buf, (unsigned int)ds->pending_buf_size);
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
ds->d_buf = overlay + ds->lit_bufsize/sizeof(uint16_t);
* (See also flush_pending()).
*/
ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size) {
- unsigned len = strm->avail_in;
+ uint32_t len = strm->avail_in;
if (len > size)
len = size;
* Initialize the "longest match" routines for a new zlib stream
*/
local void lm_init(deflate_state *s) {
- s->window_size = (ulg)2L*s->w_size;
+ s->window_size = (unsigned long)2L*s->w_size;
CLEAR_HASH(s);
register unsigned n;
register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
+ unsigned int wsize = s->w_size;
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
+ more = (unsigned)(s->window_size -(unsigned long)s->lookahead -(unsigned long)s->strstart);
/* If the window is almost full and there is insufficient lookahead,
* move the upper half to the lower one to make room in the upper half.
/* Initialize the hash value now that we have some input: */
if (s->lookahead + s->insert >= MIN_MATCH) {
- uInt str = s->strstart - s->insert;
+ unsigned int str = s->strstart - s->insert;
s->ins_h = s->window[str];
if (str >= 1)
UPDATE_HASH(s, s->ins_h, str + 1 - (MIN_MATCH-1));
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
*/
if (s->high_water < s->window_size) {
- ulg curr = s->strstart + (ulg)(s->lookahead);
- ulg init;
+ unsigned long curr = s->strstart + (unsigned long)(s->lookahead);
+ unsigned long init;
if (s->high_water < curr) {
/* Previous high water mark below current data -- zero WIN_INIT
init = WIN_INIT;
memset(s->window + curr, 0, (unsigned)init);
s->high_water = curr + init;
- } else if (s->high_water < (ulg)curr + WIN_INIT) {
+ } else if (s->high_water < (unsigned long)curr + WIN_INIT) {
/* High water mark at or above current data, but below current data
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
* to end of window, whichever is less.
*/
- init = (ulg)curr + WIN_INIT - s->high_water;
+ init = (unsigned long)curr + WIN_INIT - s->high_water;
if (init > s->window_size - s->high_water)
init = s->window_size - s->high_water;
memset(s->window + s->high_water, 0, (unsigned)init);
}
}
- Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
+ Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD,
"not enough room for search");
}
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
* to pending_buf_size, and each stored block has a 5 byte header:
*/
- ulg max_block_size = 0xffff;
- ulg max_start;
+ unsigned long max_block_size = 0xffff;
+ unsigned long max_start;
if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
+ max_block_size = (uint32_t)(s->pending_buf_size - 5);
}
/* Copy as much as possible from input to output: */
/* Emit a stored block if pending_buf will be full: */
max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
+ if (s->strstart == 0 || (unsigned long)s->strstart >= max_start) {
/* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
+ s->lookahead = (unsigned int)(s->strstart - max_start);
+ s->strstart = (unsigned int)max_start;
FLUSH_BLOCK(s, 0);
}
/* Flush if we may have to slide, otherwise block_start may become
* negative and the data will be gone:
*/
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
+ if (s->strstart - (unsigned int)s->block_start >= MAX_DIST(s)) {
FLUSH_BLOCK(s, 0);
}
}
* deflate switches away from Z_RLE.)
*/
local block_state deflate_rle(deflate_state *s, int flush) {
- int bflush; /* set if current block must be flushed */
- uInt prev; /* byte at distance one to match */
+ int bflush; /* set if current block must be flushed */
+ unsigned int prev; /* byte at distance one to match */
unsigned char *scan, *strend; /* scan goes up to strend for length of run */
for (;;) {
if (s->match_length > s->lookahead)
s->match_length = s->lookahead;
}
- Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
+ Assert(scan <= s->window+(unsigned int)(s->window_size-1), "wild scan");
}
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
*/
typedef struct internal_state {
- z_stream *strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- unsigned char *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- unsigned char *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
- unsigned char method; /* can only be DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
+ z_stream *strm; /* pointer back to this zlib stream */
+ int status; /* as the name implies */
+ unsigned char *pending_buf; /* output still pending */
+ unsigned long pending_buf_size; /* size of pending_buf */
+ unsigned char *pending_out; /* next pending byte to output to the stream */
+ unsigned int pending; /* nb of bytes in the pending buffer */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ gz_headerp gzhead; /* gzip header information to write */
+ unsigned int gzindex; /* where in extra, name, or comment */
+ unsigned char method; /* can only be DEFLATED */
+ int last_flush; /* value of flush param for previous deflate call */
#ifdef X86_PCLMULQDQ_CRC
unsigned ALIGNED_(16) crc0[4 * 5];
/* used by deflate.c: */
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
+ unsigned int w_size; /* LZ77 window size (32K by default) */
+ unsigned int w_bits; /* log2(w_size) (8..16) */
+ unsigned int w_mask; /* w_size - 1 */
unsigned char *window;
/* Sliding window. Input bytes are read into the second half of the window,
* To do: use the user input buffer as sliding window.
*/
- ulg window_size;
+ unsigned long window_size;
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
Pos *head; /* Heads of the hash chains or NIL. */
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
+ unsigned int ins_h; /* hash index of string to be inserted */
+ unsigned int hash_size; /* number of elements in hash table */
+ unsigned int hash_bits; /* log2(hash_size) */
+ unsigned int hash_mask; /* hash_size-1 */
- uInt hash_shift;
+ unsigned int hash_shift;
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* negative when the window is moved backwards.
*/
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
+ unsigned int match_length; /* length of best match */
+ IPos prev_match; /* previous match */
+ int match_available; /* set if previous match exists */
+ unsigned int strstart; /* start of string to insert */
+ unsigned int match_start; /* start of matching string */
+ unsigned int lookahead; /* number of valid bytes ahead in window */
- uInt prev_length;
+ unsigned int prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
- uInt max_chain_length;
+ unsigned int max_chain_length;
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
- uInt max_lazy_match;
+ unsigned int max_lazy_match;
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/
- uInt good_match;
+ unsigned int good_match;
/* Use a faster search when the previous match is longer than this */
int nice_match; /* Stop searching when current match exceeds this */
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
- unsigned char *l_buf; /* buffer for literals or lengths */
+ unsigned char *l_buf; /* buffer for literals or lengths */
- uInt lit_bufsize;
+ unsigned int lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - I can't count above 4
*/
- uInt last_lit; /* running index in l_buf */
+ unsigned int last_lit; /* running index in l_buf */
uint16_t *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* array would be necessary.
*/
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- uInt insert; /* bytes at end of window left to insert */
+ unsigned long opt_len; /* bit length of current block with optimal trees */
+ unsigned long static_len; /* bit length of current block with static trees */
+ unsigned int matches; /* number of string matches in current block */
+ unsigned int insert; /* bytes at end of window left to insert */
#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
+ unsigned long compressed_len; /* total bit length of compressed file mod 2^32 */
+ unsigned long bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
uint16_t bi_buf;
* are always zero.
*/
- ulg high_water;
+ unsigned long high_water;
/* High water mark offset in window for initialized bytes -- bytes above
* this are set to zero in order to avoid memory check warnings when
* longest match routines access bytes past the input. This is then
/* in trees.c */
void ZLIB_INTERNAL _tr_init(deflate_state *s);
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
-void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, ulg stored_len, int last);
+void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last);
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
void ZLIB_INTERNAL _tr_align(deflate_state *s);
-void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, ulg stored_len, int last);
+void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last);
void ZLIB_INTERNAL bi_windup(deflate_state *s);
#define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
local void send_bits(deflate_state *s, int value, int length) {
Tracevv((stderr, " l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
+ s->bits_sent += (unsigned long)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))
#include "match.h"
struct match {
- uInt match_start;
- uInt match_length;
- uInt strstart;
- uInt orgstart;
+ unsigned int match_start;
+ unsigned int match_length;
+ unsigned int strstart;
+ unsigned int orgstart;
};
#define MAX_DIST2 ((1 << MAX_WBITS) - MIN_LOOKAHEAD)
#include <fcntl.h>
#include "zlib.h"
-#ifdef _WIN32
+#ifdef WIN32
# include <stddef.h>
#endif
-#if defined(_MSC_VER) || defined(_WIN32)
+#if defined(_MSC_VER) || defined(WIN32)
# include <io.h>
#endif
#include "gzguts.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(WIN32) && !defined(__BORLANDC__)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
-#if defined(_WIN32) || defined(__MINGW__)
+#if defined(WIN32) || defined(__MINGW__)
fd == -2 ? _wopen(path, oflag, 0666) :
#elif __CYGWIN__
fd == -2 ? open(state->path, oflag, 0666) :
do { \
PULL(); \
have--; \
- hold += (unsigned long)(*next++) << bits; \
+ hold += (*next++ << bits); \
bits += 8; \
} while (0)
/* Return the low n bits of the bit accumulator (n < 16) */
#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
+ (hold & ((1U << (n)) - 1))
/* Remove n bits from the bit accumulator */
#define DROPBITS(n) \
*/
int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) {
struct inflate_state *state;
- const unsigned char *next; /* next input */
- unsigned char *put; /* next output */
+ const unsigned char *next; /* next input */
+ unsigned char *put; /* next output */
unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
+ uint32_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */
- unsigned char *from; /* where to copy match bytes from */
+ unsigned char *from; /* where to copy match bytes from */
code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
state->mode = BAD;
break;
}
- state->length = (unsigned)hold & 0xffff;
+ state->length = (uint16_t)hold;
Tracev((stderr, "inflate: stored length %u\n", state->length));
INITBITS();
while (state->have < state->nlen + state->ndist) {
for (;;) {
here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits)
+ if (here.bits <= bits)
break;
PULLBYTE();
}
/* get a literal, length, or end-of-block code */
for (;;) {
here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits)
+ if (here.bits <= bits)
break;
PULLBYTE();
}
for (;;) {
here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits)
+ if ((unsigned)last.bits + (unsigned)here.bits <= bits)
break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
- state->length = (unsigned)here.val;
+ state->length = here.val;
/* process literal */
if (here.op == 0) {
}
/* length code -- get extra bits, if any */
- state->extra = (unsigned)(here.op) & 15;
+ state->extra = (here.op & 15);
if (state->extra != 0) {
NEEDBITS(state->extra);
state->length += BITS(state->extra);
/* get distance code */
for (;;) {
here = state->distcode[BITS(state->distbits)];
- if ((unsigned)(here.bits) <= bits)
+ if (here.bits <= bits)
break;
PULLBYTE();
}
last = here;
for (;;) {
here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits)
+ if ((unsigned)last.bits + (unsigned)here.bits <= bits)
break;
PULLBYTE();
}
state->mode = BAD;
break;
}
- state->offset = (unsigned)here.val;
+ state->offset = here.val;
/* get distance extra bits, if any */
- state->extra = (unsigned)(here.op) & 15;
+ state->extra = (here.op & 15);
if (state->extra != 0) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
/* Return the low n bits of the bit accumulator (n < 16) */
#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
+ (hold & ((1U << (n)) - 1))
/* Remove n bits from the bit accumulator */
#define DROPBITS(n) \
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
-void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) {
+void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned long start) {
/* start: inflate()'s starting value for strm->avail_out */
struct inflate_state *state;
- const unsigned char *in; /* local strm->next_in */
- const unsigned char *last; /* have enough input while in < last */
- unsigned char *out; /* local strm->next_out */
- unsigned char *beg; /* inflate()'s initial strm->next_out */
- unsigned char *end; /* while out < end, enough space available */
+ const unsigned char *in; /* local strm->next_in */
+ const unsigned char *last; /* have enough input while in < last */
+ unsigned char *out; /* local strm->next_out */
+ unsigned char *beg; /* inflate()'s initial strm->next_out */
+ unsigned char *end; /* while out < end, enough space available */
#ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */
#endif
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */
- unsigned char *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
+ unsigned char *window; /* allocated sliding window, if wsize != 0 */
+ uint32_t hold; /* local strm->hold */
unsigned bits; /* local strm->bits */
- code const *lcode; /* local strm->lencode */
- code const *dcode; /* local strm->distcode */
+ code const *lcode; /* local strm->lencode */
+ code const *dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */
code here; /* retrieved table entry */
/* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */
unsigned dist; /* match distance */
- unsigned char *from; /* where to copy match from */
+ unsigned char *from; /* where to copy match from */
/* copy state to local variables */
state = (struct inflate_state *)strm->state;
input data or output space */
do {
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
}
here = lcode[hold & lmask];
dolen:
DROPBITS(here.bits);
- op = (unsigned)(here.op);
+ op = here.op;
if (op == 0) { /* literal */
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", here.val));
PUP(out) = (unsigned char)(here.val);
} else if (op & 16) { /* length base */
- len = (unsigned)(here.val);
+ len = here.val;
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
}
len += BITS(op);
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
}
here = dcode[hold & dmask];
dodist:
DROPBITS(here.bits);
- op = (unsigned)(here.op);
+ op = here.op;
if (op & 16) { /* distance base */
- dist = (unsigned)(here.val);
+ dist = here.val;
op &= 15; /* number of extra bits */
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (PUP(in) << bits);
bits += 8;
}
}
subject to change. Applications should only use zlib.h.
*/
-void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start);
+void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned long start);
#endif /* INFFAST_H_ */
/* function prototypes */
local void fixedtables(struct inflate_state *state);
-local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy);
+local int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy);
#ifdef BUILDFIXED
void makefixed(void);
#endif
-local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len);
+local uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len);
int ZEXPORT inflateResetKeep(z_stream *strm) {
struct inflate_state *state;
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.
*/
-local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) {
+local int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) {
struct inflate_state *state;
- unsigned dist;
+ uint32_t dist;
state = (struct inflate_state *)strm->state;
do { \
if (have == 0) goto inf_leave; \
have--; \
- hold += (unsigned long)(*next++) << bits; \
+ hold += (*next++ << bits); \
bits += 8; \
} while (0)
/* Return the low n bits of the bit accumulator (n < 16) */
#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
+ (hold & ((1U << (n)) - 1))
/* Remove n bits from the bit accumulator */
#define DROPBITS(n) \
int ZEXPORT inflate(z_stream *strm, int flush) {
struct inflate_state *state;
- const unsigned char *next; /* next input */
- unsigned char *put; /* next output */
+ const unsigned char *next; /* next input */
+ unsigned char *put; /* next output */
unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
+ uint32_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
+ uint32_t in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */
- unsigned char *from; /* where to copy match bytes from */
+ unsigned char *from; /* where to copy match bytes from */
code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
case EXLEN:
if (state->flags & 0x0400) {
NEEDBITS(16);
- state->length = (unsigned)(hold);
+ state->length = (uint16_t)hold;
if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
+ state->head->extra_len = (uint16_t)hold;
if (state->flags & 0x0200)
CRC2(state->check, hold);
INITBITS();
state->mode = BAD;
break;
}
- state->length = (unsigned)hold & 0xffff;
+ state->length = (uint16_t)hold;
Tracev((stderr, "inflate: stored length %u\n", state->length));
INITBITS();
state->mode = COPY_;
while (state->have < state->nlen + state->ndist) {
for (;;) {
here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits) break;
+ if (here.bits <= bits) break;
PULLBYTE();
}
if (here.val < 16) {
state->back = 0;
for (;;) {
here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits)
+ if (here.bits <= bits)
break;
PULLBYTE();
}
last = here;
for (;;) {
here = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits)
+ if ((unsigned)last.bits + (unsigned)here.bits <= bits)
break;
PULLBYTE();
}
}
DROPBITS(here.bits);
state->back += here.bits;
- state->length = (unsigned)here.val;
+ state->length = here.val;
if ((int)(here.op) == 0) {
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
state->mode = BAD;
break;
}
- state->extra = (unsigned)(here.op) & 15;
+ state->extra = (here.op & 15);
state->mode = LENEXT;
case LENEXT:
if (state->extra) {
case DIST:
for (;;) {
here = state->distcode[BITS(state->distbits)];
- if ((unsigned)(here.bits) <= bits)
+ if (here.bits <= bits)
break;
PULLBYTE();
}
last = here;
for (;;) {
here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits)
+ if ((unsigned)last.bits + (unsigned)here.bits <= bits)
break;
PULLBYTE();
}
state->mode = BAD;
break;
}
- state->offset = (unsigned)here.val;
- state->extra = (unsigned)(here.op) & 15;
+ state->offset = here.val;
+ state->extra = (here.op & 15);
state->mode = DISTEXT;
case DISTEXT:
if (state->extra) {
return Z_OK;
}
-int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt *dictLength) {
+int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength) {
struct inflate_state *state;
/* check state */
return Z_OK;
}
-int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) {
+int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength) {
struct inflate_state *state;
unsigned long dictid;
int ret;
called again with more data and the *have state. *have is initialized to
zero for the first call.
*/
-local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len) {
- unsigned got;
- unsigned next;
+local unsigned syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len) {
+ uint32_t got;
+ uint32_t next;
got = *have;
next = 0;
gz_headerp head; /* where to save gzip header information */
/* sliding window */
unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned wnext; /* window write index */
- unsigned char *window; /* allocated sliding window, if needed */
+ uint32_t wsize; /* window size or zero if not using window */
+ uint32_t whave; /* valid bytes in the window */
+ uint32_t wnext; /* window write index */
+ unsigned char *window; /* allocated sliding window, if needed */
/* bit accumulator */
- unsigned long hold; /* input bit accumulator */
+ uint32_t hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
+ uint32_t length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */
/* for table and code decoding */
unsigned extra; /* extra bits needed */
/* fixed and dynamic code tables */
- code const *lencode; /* starting table for length/literal codes */
- code const *distcode; /* starting table for distance codes */
+ code const *lencode; /* starting table for length/literal codes */
+ code const *distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */
/* dynamic table building */
unsigned ncode; /* number of code length code lengths */
unsigned nlen; /* number of length code lengths */
unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
+ uint32_t have; /* number of code lengths in lens[] */
code *next; /* next available space in codes[] */
uint16_t lens[320]; /* temporary storage for code lengths */
uint16_t work[288]; /* work area for code table building */
* Do not looks for matches beyond the end of the input. This is
* necessary to make deflate deterministic
*/
- nice_match = (uInt)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
+ nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
/*
* Stop when cur_match becomes <= limit. To simplify the code,
* Do not looks for matches beyond the end of the input. This is
* necessary to make deflate deterministic
*/
- nice_match = (uInt)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
+ nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
/*
* Stop when cur_match becomes <= limit. To simplify the code,
* then-clause of the "#ifdef UNALIGNED_OK"-directive)
*
* ------------------------------------------------------------
- * uInt longest_match(...) {
+ * unsigned int longest_match(...) {
* ...
* do {
* match = s->window + cur_match; //s0
* we prevent matches with the string of window index 0.
*/
Pos *prev = s->prev;
- uInt wmask = s->w_mask;
+ unsigned int wmask = s->w_mask;
register unsigned char *strend = s->window + s->strstart + MAX_MATCH;
register uint16_t scan_start = *(uint16_t*)scan;
/* Do not look for matches beyond the end of the input. This is necessary
* to make deflate deterministic.
*/
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+ if ((unsigned int)nice_match > s->lookahead) nice_match = s->lookahead;
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+ Assert((unsigned long)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
do {
Assert(cur_match < s->strstart, "no future");
}
} while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0);
- if ((uInt)best_len <= s->lookahead)
- return (uInt)best_len;
+ if ((unsigned int)best_len <= s->lookahead)
+ return (unsigned int)best_len;
return s->lookahead;
}
#endif
#ifndef MATCH_H_
#define MATCH_H_
-uInt longest_match (deflate_state *s, IPos cur_match);
+unsigned int longest_match (deflate_state *s, IPos cur_match);
#endif /* MATCH_H_ */
#include <string.h>
#include <stdlib.h>
+#include <inttypes.h>
#define TESTFILE "foo.gz"
*/
const char dictionary[] = "hello";
-uLong dictId; /* Adler32 value of the dictionary */
-
-void test_deflate (unsigned char *compr, uLong comprLen);
-void test_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen);
-void test_large_deflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen);
-void test_large_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen);
-void test_flush (unsigned char *compr, uLong *comprLen);
-void test_sync (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen);
-void test_dict_deflate (unsigned char *compr, uLong comprLen);
-void test_dict_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen);
+unsigned long dictId; /* Adler32 value of the dictionary */
+
+void test_deflate (unsigned char *compr, unsigned long comprLen);
+void test_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
+void test_large_deflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
+void test_large_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
+void test_flush (unsigned char *compr, unsigned long *comprLen);
+void test_sync (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
+void test_dict_deflate (unsigned char *compr, unsigned long comprLen);
+void test_dict_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
int main (int argc, char *argv[]);
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
-void test_compress (unsigned char *compr, uLong comprLen,
- unsigned char *uncompr, uLong uncomprLen);
+void test_compress (unsigned char *compr, unsigned long comprLen,
+ unsigned char *uncompr, unsigned long uncomprLen);
/* ===========================================================================
* Test compress() and uncompress()
*/
-void test_compress(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_compress(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
int err;
- uLong len = (uLong)strlen(hello)+1;
+ unsigned long len = (unsigned long)strlen(hello)+1;
err = compress(compr, &comprLen, (const unsigned char*)hello, len);
CHECK_ERR(err, "compress");
#ifdef WITH_GZFILEOP
void test_gzio (const char *fname,
- unsigned char *uncompr, uLong uncomprLen);
+ unsigned char *uncompr, unsigned long uncomprLen);
/* ===========================================================================
* Test read/write of .gz files
*/
-void test_gzio(const char *fname, unsigned char *uncompr, uLong uncomprLen)
+void test_gzio(const char *fname, unsigned char *uncompr, unsigned long uncomprLen)
{
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
/* ===========================================================================
* Test deflate() with small buffers
*/
-void test_deflate(unsigned char *compr, uLong comprLen)
+void test_deflate(unsigned char *compr, unsigned long comprLen)
{
z_stream c_stream; /* compression stream */
int err;
- uLong len = (uLong)strlen(hello)+1;
+ unsigned long len = (unsigned long)strlen(hello)+1;
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
/* ===========================================================================
* Test inflate() with small buffers
*/
-void test_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
-void test_large_deflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_large_deflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
z_stream c_stream; /* compression stream */
int err;
CHECK_ERR(err, "deflateInit");
c_stream.next_out = compr;
- c_stream.avail_out = (uInt)comprLen;
+ c_stream.avail_out = (unsigned int)comprLen;
/* At this point, uncompr is still mostly zeroes, so it should compress
* very well:
*/
c_stream.next_in = uncompr;
- c_stream.avail_in = (uInt)uncomprLen;
+ c_stream.avail_in = (unsigned int)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) {
/* Feed in already compressed data and switch to no compression: */
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
c_stream.next_in = compr;
- c_stream.avail_in = (uInt)comprLen/2;
+ c_stream.avail_in = (unsigned int)comprLen/2;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
/* Switch back to compressing mode: */
deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
c_stream.next_in = uncompr;
- c_stream.avail_in = (uInt)uncomprLen;
+ c_stream.avail_in = (unsigned int)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
/* ===========================================================================
* Test inflate() with large buffers
*/
-void test_large_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_large_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
d_stream.opaque = (void *)0;
d_stream.next_in = compr;
- d_stream.avail_in = (uInt)comprLen;
+ d_stream.avail_in = (unsigned int)comprLen;
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
for (;;) {
d_stream.next_out = uncompr; /* discard the output */
- d_stream.avail_out = (uInt)uncomprLen;
+ d_stream.avail_out = (unsigned int)uncomprLen;
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate");
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
- fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
+ fprintf(stderr, "bad large inflate: %" PRId32 "\n", d_stream.total_out);
exit(1);
} else {
printf("large_inflate(): OK\n");
/* ===========================================================================
* Test deflate() with full flush
*/
-void test_flush(unsigned char *compr, uLong *comprLen)
+void test_flush(unsigned char *compr, unsigned long *comprLen)
{
z_stream c_stream; /* compression stream */
int err;
- uInt len = (uInt)strlen(hello)+1;
+ unsigned int len = (unsigned int)strlen(hello)+1;
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.next_in = (const unsigned char *)hello;
c_stream.next_out = compr;
c_stream.avail_in = 3;
- c_stream.avail_out = (uInt)*comprLen;
+ c_stream.avail_out = (unsigned int)*comprLen;
err = deflate(&c_stream, Z_FULL_FLUSH);
CHECK_ERR(err, "deflate");
/* ===========================================================================
* Test inflateSync()
*/
-void test_sync(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_sync(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr;
- d_stream.avail_out = (uInt)uncomprLen;
+ d_stream.avail_out = (unsigned int)uncomprLen;
err = inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate");
- d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
+ d_stream.avail_in = (unsigned int)comprLen-2; /* read all compressed data */
err = inflateSync(&d_stream); /* but skip the damaged part */
CHECK_ERR(err, "inflateSync");
/* ===========================================================================
* Test deflate() with preset dictionary
*/
-void test_dict_deflate(unsigned char *compr, uLong comprLen)
+void test_dict_deflate(unsigned char *compr, unsigned long comprLen)
{
z_stream c_stream; /* compression stream */
int err;
dictId = c_stream.adler;
c_stream.next_out = compr;
- c_stream.avail_out = (uInt)comprLen;
+ c_stream.avail_out = (unsigned int)comprLen;
c_stream.next_in = (const unsigned char *)hello;
- c_stream.avail_in = (uInt)strlen(hello)+1;
+ c_stream.avail_in = (unsigned int)strlen(hello)+1;
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
-void test_dict_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen)
+void test_dict_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
d_stream.opaque = (void *)0;
d_stream.next_in = compr;
- d_stream.avail_in = (uInt)comprLen;
+ d_stream.avail_in = (unsigned int)comprLen;
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr;
- d_stream.avail_out = (uInt)uncomprLen;
+ d_stream.avail_out = (unsigned int)uncomprLen;
for (;;) {
err = inflate(&d_stream, Z_NO_FLUSH);
int main(int argc, char *argv[])
{
unsigned char *compr, *uncompr;
- uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
- uLong uncomprLen = comprLen;
+ unsigned long comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
+ unsigned long uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
- compr = (unsigned char*)calloc((uInt)comprLen, 1);
- uncompr = (unsigned char*)calloc((uInt)uncomprLen, 1);
+ compr = (unsigned char*)calloc((unsigned int)comprLen, 1);
+ uncompr = (unsigned char*)calloc((unsigned int)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
if (strm->avail_in == 0)
{
strm->next_in = gz->buf;
- strm->avail_in = (uInt)fread(gz->buf, 1, BUFLEN, gz->file);
+ strm->avail_in = (uint32_t)fread(gz->buf, 1, BUFLEN, gz->file);
}
if (strm->avail_in > 0)
{
#endif /* GEN_TREES_H */
struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const int *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
+ const ct_data *static_tree; /* static tree or NULL */
+ const int *extra_bits; /* extra bits for each code or NULL */
+ int extra_base; /* base index for extra_bits */
+ int elems; /* max number of elements in the tree */
+ unsigned int max_length; /* max bit length for the codes */
};
local const static_tree_desc static_l_desc =
*/
local void gen_bitlen(deflate_state *s, tree_desc *desc) {
/* desc: the tree descriptor */
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const int *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
+ ct_data *tree = desc->dyn_tree;
+ int max_code = desc->max_code;
+ const ct_data *stree = desc->stat_desc->static_tree;
+ const int *extra = desc->stat_desc->extra_bits;
+ int base = desc->stat_desc->extra_base;
+ unsigned int max_length = desc->stat_desc->max_length;
int h; /* heap index */
int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
+ unsigned int bits; /* bit length */
int xbits; /* extra bits */
uint16_t f; /* frequency */
int overflow = 0; /* number of elements with bit length too large */
if (n >= base)
xbits = extra[n-base];
f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
+ s->opt_len += (unsigned long)f * (bits + xbits);
if (stree)
- s->static_len += (ulg)f * (stree[n].Len + xbits);
+ s->static_len += (unsigned long)f * (stree[n].Len + xbits);
}
if (overflow == 0)
return;
m = s->heap[--h];
if (m > max_code)
continue;
- if ((unsigned) tree[m].Len != (unsigned) bits) {
+ if (tree[m].Len != bits) {
Trace((stderr, "code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len) *(long)tree[m].Freq;
+ s->opt_len += (long)((bits - tree[m].Len) * tree[m].Freq);
tree[m].Len = (uint16_t)bits;
}
n--;
/* ===========================================================================
* Send a stored block
*/
-void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, ulg stored_len, int last) {
+void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last) {
/* buf: input block */
/* stored_len: length of input block */
/* last: one if this is the last block for a file */
send_bits(s, (STORED_BLOCK << 1)+last, 3); /* send block type */
#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
+ s->compressed_len = (s->compressed_len + 3 + 7) & (unsigned long)~7L;
s->compressed_len += (stored_len + 4) << 3;
#endif
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
* Determine the best encoding for the current block: dynamic trees, static
* trees or store, and output the encoded block to the zip file.
*/
-void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, ulg stored_len, int last) {
+void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last) {
/* buf: input block, or NULL if too old */
/* stored_len: length of input block */
/* last: one if this is the last block for a file */
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
+ unsigned long opt_lenb, static_lenb; /* opt_len and static_len in bytes */
int max_blindex = 0; /* index of last bit length code of non zero freq */
/* Build the Huffman trees unless a stored block is forced */
}
Assert(s->compressed_len == s->bits_sent, "bad compressed size");
/* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
+ * and unsigned long implemented on 32 bits.
*/
init_block(s);
/* Try to guess if it is profitable to stop the current block here */
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
/* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
+ unsigned long out_length = (unsigned long)s->last_lit*8L;
+ unsigned long in_length = (unsigned long)((long)s->strstart - s->block_start);
int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]);
+ out_length += (unsigned long)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]);
}
out_length >>= 3;
Tracev((stderr, "\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
} /* literal or match pair ? */
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, "pendingBuf overflow");
+ Assert((unsigned int)(s->pending) < s->lit_bufsize + 2*lx, "pendingBuf overflow");
} while (lx < s->last_lit);
}
#endif
}
#ifdef DEBUG
- s->bits_sent += (ulg)len << 3;
+ s->bits_sent += (unsigned long)len << 3;
#endif
while (len--) {
put_byte(s, *buf++);
/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010, 2014 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2003, 2010, 2014 Jean-loup Gailly, Mark Adler.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
buffer, or Z_DATA_ERROR if the input data was corrupted, including if the
input data is an incomplete zlib stream.
*/
-int ZEXPORT uncompress(unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen) {
+int ZEXPORT uncompress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen) {
z_stream stream;
int err;
- const uInt max = (uInt)0 - 1;
- uLong left;
- Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */
+ const unsigned int max = (unsigned int)0 - 1;
+ unsigned long left;
+ unsigned char buf[1]; /* for detection of incomplete stream when *destLen == 0 */
if (*destLen) {
left = *destLen;
stream.avail_in = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
- stream.opaque = (void *)0;
+ stream.opaque = NULL;
err = inflateInit(&stream);
if (err != Z_OK) return err;
#include <sys/types.h> /* for off_t */
#include <stdarg.h> /* for va_list */
-#ifdef _WIN32
+#ifdef WIN32
# include <stddef.h> /* for wchar_t */
#endif
# define z_off_t long
#endif
-#if !defined(_WIN32) && defined(Z_LARGE64)
+#if !defined(WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#else
-# if (defined(_WIN32) || defined(WIN32)) && !defined(__GNUC__)
+# if defined(WIN32) && !defined(__GNUC__)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
even in case of corrupted input.
*/
-typedef void *(*alloc_func) (void *opaque, uInt items, uInt size);
+typedef void *(*alloc_func) (void *opaque, unsigned int items, unsigned int size);
typedef void (*free_func) (void *opaque, void *address);
struct internal_state;
typedef struct z_stream_s {
- const unsigned char *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total number of input bytes read so far */
+ const unsigned char *next_in; /* next input byte */
+ uint32_t avail_in; /* number of bytes available at next_in */
+ uint32_t total_in; /* total number of input bytes read so far */
- unsigned char *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total number of bytes output so far */
+ unsigned char *next_out; /* next output byte should be put there */
+ uint32_t avail_out; /* remaining free space at next_out */
+ uint32_t total_out; /* total number of bytes output so far */
- const char *msg; /* last error message, NULL if no error */
- struct internal_state *state; /* not visible by applications */
+ const char *msg; /* last error message, NULL if no error */
+ struct internal_state *state; /* not visible by applications */
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- void *opaque; /* private data object passed to zalloc and zfree */
+ alloc_func zalloc; /* used to allocate the internal state */
+ free_func zfree; /* used to free the internal state */
+ void *opaque; /* private data object passed to zalloc and zfree */
- int data_type; /* best guess about the data type: binary or text */
- uint32_t adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
+ int data_type; /* best guess about the data type: binary or text */
+ uint32_t adler; /* adler32 value of the uncompressed data */
+ unsigned long reserved; /* reserved for future use */
} z_stream;
typedef z_stream *z_streamp; // Obsolete type, retained for compatability only
for more details on the meanings of these fields.
*/
typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
+ int text; /* true if compressed data believed to be text */
+ unsigned long time; /* modification time */
+ int xflags; /* extra flags (not used when writing a gzip file) */
+ int os; /* operating system */
unsigned char *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
+ unsigned int extra_len; /* extra field length (valid if extra != Z_NULL) */
+ unsigned int extra_max; /* space at extra (only when reading header) */
unsigned char *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
+ unsigned int name_max; /* space at name (only when reading header) */
unsigned char *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used when writing a gzip file) */
+ unsigned int comm_max; /* space at comment (only when reading header) */
+ int hcrc; /* true if there was or will be a header crc */
+ int done; /* true when done reading gzip header (not used when writing a gzip file) */
} gz_header;
typedef gz_header *gz_headerp;
ZEXTERN int ZEXPORT deflateSetDictionary(z_stream *strm,
const unsigned char *dictionary,
- uInt dictLength);
+ unsigned int dictLength);
/*
Initializes the compression dictionary from the given byte sequence
without producing any compressed output. When using the zlib format, this
returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
*/
-ZEXTERN uLong ZEXPORT deflateBound(z_stream *strm, uLong sourceLen);
+ZEXTERN unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen);
/*
deflateBound() returns an upper bound on the compressed size after
deflation of sourceLen bytes. It must be called after deflateInit() or
than Z_FINISH or Z_NO_FLUSH are used.
*/
-ZEXTERN int ZEXPORT deflatePending(z_stream *strm, unsigned *pending, int *bits);
+ZEXTERN int ZEXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits);
/*
deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not
deferred until inflate() is called.
*/
-ZEXTERN int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength);
+ZEXTERN int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength);
/*
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate,
inflate().
*/
-ZEXTERN int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt *dictLength);
+ZEXTERN int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength);
/*
Returns the sliding dictionary being maintained by inflate. dictLength is
set to the number of bytes in the dictionary, and that many bytes are copied
the version of the header file.
*/
-typedef unsigned (*in_func) (void *, const unsigned char * *);
-typedef int (*out_func) (void *, unsigned char *, unsigned);
+typedef uint32_t (*in_func) (void *, const unsigned char * *);
+typedef int (*out_func) (void *, unsigned char *, uint32_t);
ZEXTERN int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc);
/*
state was inconsistent.
*/
-ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
+ZEXTERN unsigned long ZEXPORT zlibCompileFlags(void);
/* Return flags indicating compile-time options.
Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
+ 1.0: size of unsigned int
+ 3.2: size of unsigned long
5.4: size of void * (pointer)
7.6: size of z_off_t
you need special options.
*/
-ZEXTERN int ZEXPORT compress(unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen);
+ZEXTERN int ZEXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen);
/*
Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
buffer.
*/
-ZEXTERN int ZEXPORT compress2(unsigned char *dest, uLong *destLen, const unsigned char *source,
- uLong sourceLen, int level);
+ZEXTERN int ZEXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source,
+ unsigned long sourceLen, int level);
/*
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
Z_STREAM_ERROR if the level parameter is invalid.
*/
-ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
+ZEXTERN unsigned long ZEXPORT compressBound(unsigned long sourceLen);
/*
compressBound() returns an upper bound on the compressed size after
compress() or compress2() on sourceLen bytes. It would be used before a
compress() or compress2() call to allocate the destination buffer.
*/
-ZEXTERN int ZEXPORT uncompress(unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen);
+ZEXTERN int ZEXPORT uncompress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen);
/*
Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
library.
*/
-ZEXTERN uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len);
+ZEXTERN uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint32_t len);
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
return the updated checksum. If buf is Z_NULL, this function returns the
negative, the result has no meaning or utility.
*/
-ZEXTERN uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, uInt len);
+ZEXTERN uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, z_off64_t len);
/*
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
*/
/*
-ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t crc1, uint32_t crc2, z_off_t len2);
+ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2);
Combine two CRC-32 check values into one. For two sequences of bytes,
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
/* undocumented functions */
-ZEXTERN const char * ZEXPORT zError(int);
-ZEXTERN int ZEXPORT inflateSyncPoint(z_stream *);
-ZEXTERN const uint32_t * ZEXPORT get_crc_table(void);
-ZEXTERN int ZEXPORT inflateUndermine(z_stream *, int);
-ZEXTERN int ZEXPORT inflateResetKeep(z_stream *);
-ZEXTERN int ZEXPORT deflateResetKeep(z_stream *);
+ZEXTERN const char * ZEXPORT zError (int);
+ZEXTERN int ZEXPORT inflateSyncPoint (z_stream *);
+ZEXTERN const uint32_t * ZEXPORT get_crc_table (void);
+ZEXTERN int ZEXPORT inflateUndermine (z_stream *, int);
+ZEXTERN int ZEXPORT inflateResetKeep (z_stream *);
+ZEXTERN int ZEXPORT deflateResetKeep (z_stream *);
#ifdef WITH_GZFILEOP
-# if (defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__))
+# if (defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW__))
ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode);
# endif
ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va);
return ZLIB_VERSION;
}
-uLong ZEXPORT zlibCompileFlags(void)
+unsigned long ZEXPORT zlibCompileFlags(void)
{
- uLong flags;
+ unsigned long flags;
flags = 0;
- switch ((int)(sizeof(uInt))) {
+ switch ((int)(sizeof(unsigned int))) {
case 2: break;
case 4: flags += 1; break;
case 8: flags += 2; break;
default: flags += 3;
}
- switch ((int)(sizeof(uLong))) {
+ switch ((int)(sizeof(unsigned long))) {
case 2: break;
case 4: flags += 1 << 2; break;
case 8: flags += 2 << 2; break;
void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size)
{
(void)opaque;
- return sizeof(uInt) > 2 ? (void *)malloc(items * size) :
+ return sizeof(unsigned int) > 2 ? (void *)malloc(items * size) :
(void *)calloc(items, size);
}
#endif
/* provide prototypes for these when building zlib without LFS */
-#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+#if !defined(WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t);
#endif
/* Reverse the bytes in a 32-bit value. Use compiler intrinsics when
possible to take advantage of hardware implementations. */
-#if defined(_WIN32) && (_MSC_VER >= 1300)
+#if defined(WIN32) && (_MSC_VER >= 1300)
# pragma intrinsic(_byteswap_ulong)
# define ZSWAP32(q) _byteswap_ulong(q)