From: Mika Lindqvist Date: Mon, 18 May 2015 19:11:02 +0000 (+0300) Subject: Replace 'unsigned long' with most suitable fixed-size type. X-Git-Tag: 1.9.9-b1~807 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edd7a72e056b994458ff040d4740b16b35336b60;p=thirdparty%2Fzlib-ng.git Replace 'unsigned long' with most suitable fixed-size type. --- diff --git a/arch/x86/crc_folding.c b/arch/x86/crc_folding.c index 7b04890d0..199dae85b 100644 --- a/arch/x86/crc_folding.c +++ b/arch/x86/crc_folding.c @@ -273,7 +273,7 @@ local void partial_fold(deflate_state *const s, const size_t len, ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const unsigned char *src, long len) { - unsigned long algn_diff; + uintptr_t algn_diff; __m128i xmm_t0, xmm_t1, xmm_t2, xmm_t3; CRC_LOAD(s) diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index 70c6ca9cc..41be0b98a 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -19,15 +19,15 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); - register unsigned n; + register uint32_t n; register Pos *p; - unsigned more; /* Amount of free space at the end of the window. */ + uint32_t more; /* Amount of free space at the end of the window. */ uInt 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 = (uint32_t)(s->window_size -(uint32_t)s->lookahead -(uint32_t)s->strstart); /* Deal with !@#$% 64K limit: */ if (sizeof(int) <= 2) { @@ -138,8 +138,8 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) * 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; + uint32_t curr = s->strstart + (uint32_t)(s->lookahead); + uint32_t init; if (s->high_water < curr) { /* Previous high water mark below current data -- zero WIN_INIT @@ -151,12 +151,12 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) 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 < 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 = 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); @@ -164,7 +164,7 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) } } - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + Assert(s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); } #endif diff --git a/deflate.c b/deflate.c index 96e11fdfc..085ca9ac6 100644 --- a/deflate.c +++ b/deflate.c @@ -332,7 +332,7 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, 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 = (uint32_t)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) { @@ -1101,7 +1101,7 @@ ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size) */ local void lm_init (deflate_state *s) { - s->window_size = (ulg)2L*s->w_size; + s->window_size = (uint32_t)2L*s->w_size; CLEAR_HASH(s); @@ -1183,13 +1183,13 @@ local void fill_window_c(deflate_state *s) { register unsigned n; register Pos *p; - unsigned more; /* Amount of free space at the end of the window. */ + uint32_t more; /* Amount of free space at the end of the window. */ uInt 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 = (uint32_t)(s->window_size -(uint32_t)s->lookahead -(uint32_t)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. @@ -1310,8 +1310,8 @@ local void fill_window_c(deflate_state *s) * 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; + uint32_t curr = s->strstart + (uint32_t)(s->lookahead); + uint32_t init; if (s->high_water < curr) { /* Previous high water mark below current data -- zero WIN_INIT @@ -1323,12 +1323,12 @@ local void fill_window_c(deflate_state *s) 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 < 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 = 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); @@ -1336,7 +1336,7 @@ local void fill_window_c(deflate_state *s) } } - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + Assert(s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); } @@ -1348,7 +1348,7 @@ local void fill_window_c(deflate_state *s) _tr_flush_block(s, (s->block_start >= 0L ? \ (char *)&s->window[(unsigned)s->block_start] : \ (char *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ + (uint16_t)((int32_t)s->strstart - s->block_start), \ (last)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ @@ -1375,8 +1375,8 @@ local block_state deflate_stored(deflate_state *s, int flush) /* 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; + uint32_t max_block_size = 0xffff; + uint32_t max_start; if (max_block_size > s->pending_buf_size - 5) { max_block_size = s->pending_buf_size - 5; @@ -1402,7 +1402,7 @@ local block_state deflate_stored(deflate_state *s, int flush) /* 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 || 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; diff --git a/deflate.h b/deflate.h index baf7bf12d..51f23eaf8 100644 --- a/deflate.h +++ b/deflate.h @@ -101,17 +101,17 @@ typedef unsigned IPos; */ 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 */ + uint16_t 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 */ #ifdef X86_PCLMULQDQ_CRC unsigned __attribute__((aligned(16))) crc0[4 * 5]; @@ -133,7 +133,7 @@ typedef struct internal_state { * To do: use the user input buffer as sliding window. */ - ulg window_size; + uint32_t window_size; /* Actual size of window: 2*wSize, except when the user input buffer * is directly used as sliding window. */ @@ -254,14 +254,14 @@ typedef struct internal_state { * 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 */ + uint32_t opt_len; /* bit length of current block with optimal trees */ + uint32_t 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 */ #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 */ + uint32_t compressed_len; /* total bit length of compressed file mod 2^32 */ + uint32_t bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif uint16_t bi_buf; @@ -273,7 +273,7 @@ typedef struct internal_state { * are always zero. */ - ulg high_water; + uint32_t 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 @@ -336,10 +336,10 @@ typedef enum { /* 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, uint16_t 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, uint16_t stored_len, int last); void ZLIB_INTERNAL bi_windup (deflate_state *s); #define d_code(dist) \ @@ -427,7 +427,7 @@ local void send_bits(deflate_state *s, { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; + s->bits_sent += (uint32_t)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)) diff --git a/infback.c b/infback.c index ead697bd6..8581177ef 100644 --- a/infback.c +++ b/infback.c @@ -160,7 +160,7 @@ local void fixedtables(struct inflate_state *state) do { \ PULL(); \ have--; \ - hold += (unsigned long)(*next++) << bits; \ + hold += (uint32_t)(*next++) << bits; \ bits += 8; \ } while (0) @@ -238,13 +238,13 @@ 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 */ diff --git a/inffast.c b/inffast.c index cd56802df..1ccaeae03 100644 --- a/inffast.c +++ b/inffast.c @@ -77,22 +77,22 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned 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 */ @@ -127,9 +127,9 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) input data or output space */ do { if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; } here = lcode[hold & lmask]; @@ -147,7 +147,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) op &= 15; /* number of extra bits */ if (op) { if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; } len += BITS(op); @@ -155,9 +155,9 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; } here = dcode[hold & dmask]; @@ -168,10 +168,10 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) dist = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (uint32_t)(PUP(in)) << bits; bits += 8; } } diff --git a/inflate.c b/inflate.c index 24a4b4f3f..2d9aa1c28 100644 --- a/inflate.c +++ b/inflate.c @@ -463,7 +463,7 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) do { \ if (have == 0) goto inf_leave; \ have--; \ - hold += (unsigned long)(*next++) << bits; \ + hold += (uint32_t)(*next++) << bits; \ bits += 8; \ } while (0) @@ -579,13 +579,13 @@ int ZEXPORT inflate(z_stream *strm, int flush) { struct inflate_state *state; const unsigned char *next; /* next input */ - unsigned char *put; /* next output */ + 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 */ 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 */ @@ -1258,7 +1258,7 @@ int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) { struct inflate_state *state; - unsigned long dictid; + uint32_t dictid; int ret; /* check state */ @@ -1336,7 +1336,7 @@ local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len int ZEXPORT inflateSync(z_stream *strm) { unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ + size_t in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state *state; diff --git a/inflate.h b/inflate.h index c6e7ff8e4..5e640c705 100644 --- a/inflate.h +++ b/inflate.h @@ -85,8 +85,8 @@ struct inflate_state { int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ + size_t check; /* protected copy of check value */ + size_t total; /* protected copy of output count */ gz_headerp head; /* where to save gzip header information */ /* sliding window */ unsigned wbits; /* log base 2 of requested window size */ @@ -95,7 +95,7 @@ struct inflate_state { unsigned 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 */ diff --git a/match.c b/match.c index a56d1b749..ae9256692 100644 --- a/match.c +++ b/match.c @@ -72,7 +72,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; - Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, + Assert((size_t)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); @@ -193,7 +193,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) scan_start = *(uint16_t *)scan; scan_end = *(uint16_t *)(scan + best_len-1); - Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, + Assert((size_t)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); do { unsigned char *match; @@ -368,7 +368,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) */ if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + Assert((size_t)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); @@ -413,17 +413,17 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) scan += 2, match+=2; Assert(*scan == *match, "match[2]?"); do { - unsigned long sv = *(unsigned long*)(void*)scan; - unsigned long mv = *(unsigned long*)(void*)match; - unsigned long xor = sv ^ mv; + uintptr_t sv = *(uintptr_t*)(void*)scan; + uintptr_t mv = *(uintptr_t*)(void*)match; + uintptr_t xor = sv ^ mv; if (xor) { int match_byte = __builtin_ctzl(xor) / 8; scan += match_byte; match += match_byte; break; } else { - scan += sizeof(unsigned long); - match += sizeof(unsigned long); + scan += sizeof(uintptr_t); + match += sizeof(uintptr_t); } } while (scan < strend); diff --git a/trees.c b/trees.c index cc639f496..231daaa16 100644 --- a/trees.c +++ b/trees.c @@ -146,7 +146,7 @@ local void compress_block (deflate_state *s, const ct_data *ltree, const ct_data local int detect_data_type (deflate_state *s); local unsigned bi_reverse (unsigned value, int length); local void bi_flush (deflate_state *s); -local void copy_block (deflate_state *s, char *buf, unsigned len, int header); +local void copy_block (deflate_state *s, char *buf, uint16_t len, int header); #ifdef GEN_TREES_H local void gen_trees_header (void); @@ -442,8 +442,8 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc) xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + s->opt_len += (size_t)f * (bits + xbits); + if (stree) s->static_len += (size_t)f * (stree[n].Len + xbits); } if (overflow == 0) return; @@ -777,16 +777,16 @@ local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) * Send a stored block */ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, - char *buf, /* input block */ - ulg stored_len, /* length of input block */ - int last) /* one if this is the last block for a file */ + char *buf, /* input block */ + uint16_t stored_len, /* length of input block */ + int 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) & (uint32_t)~7L; s->compressed_len += (stored_len + 4) << 3; #endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ + copy_block(s, buf, stored_len, 1); /* with header */ } /* =========================================================================== @@ -815,12 +815,12 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s) * 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, uint16_t 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 */ + uint16_t 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 */ @@ -942,11 +942,11 @@ int ZLIB_INTERNAL _tr_tally (deflate_state *s, unsigned dist, unsigned lc) /* 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); + size_t out_length = (size_t)s->last_lit*8L; + size_t in_length = (size_t)((long)s->strstart - s->block_start); int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * + out_length += (size_t)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]); } out_length >>= 3; @@ -1031,7 +1031,7 @@ local int detect_data_type(deflate_state *s) * set bits 0..6, 14..25, and 28..31 * 0xf3ffc07f = binary 11110011111111111100000001111111 */ - unsigned long black_mask = 0xf3ffc07fUL; + uint32_t black_mask = 0xf3ffc07fUL; int n; /* Check for non-textual ("black-listed") bytes. */ @@ -1107,7 +1107,7 @@ ZLIB_INTERNAL void bi_windup(deflate_state *s) * Copy a stored block, storing first the length and its * one's complement if requested. */ -local void copy_block(deflate_state *s, char *buf, unsigned len, int header) +local void copy_block(deflate_state *s, char *buf, uint16_t len, int header) { /* buf: the input data */ /* len: its length */ @@ -1122,7 +1122,7 @@ local void copy_block(deflate_state *s, char *buf, unsigned len, int header) #endif } #ifdef DEBUG - s->bits_sent += (ulg)len<<3; + s->bits_sent += (uint32_t)len<<3; #endif while (len--) { put_byte(s, *buf++);