diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2016-10-11 22:15:50 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2016-10-11 22:15:50 -0700 |
commit | 7096424f23df1b1813237fb5f8bc8f34cfcedd0c (patch) | |
tree | c41e8ef447e7e6764be5f3ba822fdc0c8da049f1 | |
parent | 2edb94a3025d288dc251bc6cbb2c02e60fbd7438 (diff) | |
download | zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.tar.gz zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.tar.bz2 zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.zip |
Clean up type conversions.
-rw-r--r-- | deflate.c | 24 | ||||
-rw-r--r-- | deflate.h | 6 | ||||
-rw-r--r-- | gzread.c | 8 | ||||
-rw-r--r-- | gzwrite.c | 22 | ||||
-rw-r--r-- | infback.c | 2 | ||||
-rw-r--r-- | inflate.c | 15 | ||||
-rw-r--r-- | trees.c | 20 | ||||
-rw-r--r-- | zlib.h | 1 | ||||
-rw-r--r-- | zutil.c | 21 |
9 files changed, 62 insertions, 57 deletions
@@ -84,7 +84,7 @@ local block_state deflate_huff OF((deflate_state *s, int flush)); | |||
84 | local void lm_init OF((deflate_state *s)); | 84 | local void lm_init OF((deflate_state *s)); |
85 | local void putShortMSB OF((deflate_state *s, uInt b)); | 85 | local void putShortMSB OF((deflate_state *s, uInt b)); |
86 | local void flush_pending OF((z_streamp strm)); | 86 | local void flush_pending OF((z_streamp strm)); |
87 | local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); | 87 | local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); |
88 | #ifdef ASMV | 88 | #ifdef ASMV |
89 | void match_init OF((void)); /* asm code initialization */ | 89 | void match_init OF((void)); /* asm code initialization */ |
90 | uInt longest_match OF((deflate_state *s, IPos cur_match)); | 90 | uInt longest_match OF((deflate_state *s, IPos cur_match)); |
@@ -277,11 +277,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |||
277 | 277 | ||
278 | s->wrap = wrap; | 278 | s->wrap = wrap; |
279 | s->gzhead = Z_NULL; | 279 | s->gzhead = Z_NULL; |
280 | s->w_bits = windowBits; | 280 | s->w_bits = (uInt)windowBits; |
281 | s->w_size = 1 << s->w_bits; | 281 | s->w_size = 1 << s->w_bits; |
282 | s->w_mask = s->w_size - 1; | 282 | s->w_mask = s->w_size - 1; |
283 | 283 | ||
284 | s->hash_bits = memLevel + 7; | 284 | s->hash_bits = (uInt)memLevel + 7; |
285 | s->hash_size = 1 << s->hash_bits; | 285 | s->hash_size = 1 << s->hash_bits; |
286 | s->hash_mask = s->hash_size - 1; | 286 | s->hash_mask = s->hash_size - 1; |
287 | s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); | 287 | s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); |
@@ -534,10 +534,10 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) | |||
534 | 534 | ||
535 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; | 535 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; |
536 | s = strm->state; | 536 | s = strm->state; |
537 | s->good_match = good_length; | 537 | s->good_match = (uInt)good_length; |
538 | s->max_lazy_match = max_lazy; | 538 | s->max_lazy_match = (uInt)max_lazy; |
539 | s->nice_match = nice_length; | 539 | s->nice_match = nice_length; |
540 | s->max_chain_length = max_chain; | 540 | s->max_chain_length = (uInt)max_chain; |
541 | return Z_OK; | 541 | return Z_OK; |
542 | } | 542 | } |
543 | 543 | ||
@@ -1068,7 +1068,7 @@ int ZEXPORT deflateCopy (dest, source) | |||
1068 | * allocating a large strm->next_in buffer and copying from it. | 1068 | * allocating a large strm->next_in buffer and copying from it. |
1069 | * (See also flush_pending()). | 1069 | * (See also flush_pending()). |
1070 | */ | 1070 | */ |
1071 | local int read_buf(strm, buf, size) | 1071 | local unsigned read_buf(strm, buf, size) |
1072 | z_streamp strm; | 1072 | z_streamp strm; |
1073 | Bytef *buf; | 1073 | Bytef *buf; |
1074 | unsigned size; | 1074 | unsigned size; |
@@ -1092,7 +1092,7 @@ local int read_buf(strm, buf, size) | |||
1092 | strm->next_in += len; | 1092 | strm->next_in += len; |
1093 | strm->total_in += len; | 1093 | strm->total_in += len; |
1094 | 1094 | ||
1095 | return (int)len; | 1095 | return len; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | /* =========================================================================== | 1098 | /* =========================================================================== |
@@ -1148,7 +1148,7 @@ local uInt longest_match(s, cur_match) | |||
1148 | register Bytef *scan = s->window + s->strstart; /* current string */ | 1148 | register Bytef *scan = s->window + s->strstart; /* current string */ |
1149 | register Bytef *match; /* matched string */ | 1149 | register Bytef *match; /* matched string */ |
1150 | register int len; /* length of current match */ | 1150 | register int len; /* length of current match */ |
1151 | int best_len = s->prev_length; /* best match length so far */ | 1151 | int best_len = (int)s->prev_length; /* best match length so far */ |
1152 | int nice_match = s->nice_match; /* stop if match long enough */ | 1152 | int nice_match = s->nice_match; /* stop if match long enough */ |
1153 | IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | 1153 | IPos limit = s->strstart > (IPos)MAX_DIST(s) ? |
1154 | s->strstart - (IPos)MAX_DIST(s) : NIL; | 1154 | s->strstart - (IPos)MAX_DIST(s) : NIL; |
@@ -1183,7 +1183,7 @@ local uInt longest_match(s, cur_match) | |||
1183 | /* Do not look for matches beyond the end of the input. This is necessary | 1183 | /* Do not look for matches beyond the end of the input. This is necessary |
1184 | * to make deflate deterministic. | 1184 | * to make deflate deterministic. |
1185 | */ | 1185 | */ |
1186 | if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | 1186 | if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; |
1187 | 1187 | ||
1188 | Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); | 1188 | Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); |
1189 | 1189 | ||
@@ -1589,7 +1589,7 @@ local block_state deflate_stored(s, flush) | |||
1589 | s->lookahead = 0; | 1589 | s->lookahead = 0; |
1590 | 1590 | ||
1591 | /* Emit a stored block if pending_buf will be full: */ | 1591 | /* Emit a stored block if pending_buf will be full: */ |
1592 | max_start = s->block_start + max_block_size; | 1592 | max_start = max_block_size + (ulg)s->block_start; |
1593 | if (s->strstart == 0 || (ulg)s->strstart >= max_start) { | 1593 | if (s->strstart == 0 || (ulg)s->strstart >= max_start) { |
1594 | /* strstart == 0 is possible when wraparound on 16-bit machine */ | 1594 | /* strstart == 0 is possible when wraparound on 16-bit machine */ |
1595 | s->lookahead = (uInt)(s->strstart - max_start); | 1595 | s->lookahead = (uInt)(s->strstart - max_start); |
@@ -1887,7 +1887,7 @@ local block_state deflate_rle(s, flush) | |||
1887 | prev == *++scan && prev == *++scan && | 1887 | prev == *++scan && prev == *++scan && |
1888 | prev == *++scan && prev == *++scan && | 1888 | prev == *++scan && prev == *++scan && |
1889 | scan < strend); | 1889 | scan < strend); |
1890 | s->match_length = MAX_MATCH - (int)(strend - scan); | 1890 | s->match_length = MAX_MATCH - (uInt)(strend - scan); |
1891 | if (s->match_length > s->lookahead) | 1891 | if (s->match_length > s->lookahead) |
1892 | s->match_length = s->lookahead; | 1892 | s->match_length = s->lookahead; |
1893 | } | 1893 | } |
@@ -275,7 +275,7 @@ typedef struct internal_state { | |||
275 | /* Output a byte on the stream. | 275 | /* Output a byte on the stream. |
276 | * IN assertion: there is enough room in pending_buf. | 276 | * IN assertion: there is enough room in pending_buf. |
277 | */ | 277 | */ |
278 | #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} | 278 | #define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} |
279 | 279 | ||
280 | 280 | ||
281 | #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) | 281 | #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) |
@@ -328,8 +328,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | |||
328 | flush = (s->last_lit == s->lit_bufsize-1); \ | 328 | flush = (s->last_lit == s->lit_bufsize-1); \ |
329 | } | 329 | } |
330 | # define _tr_tally_dist(s, distance, length, flush) \ | 330 | # define _tr_tally_dist(s, distance, length, flush) \ |
331 | { uch len = (length); \ | 331 | { uch len = (uch)(length); \ |
332 | ush dist = (distance); \ | 332 | ush dist = (ush)(distance); \ |
333 | s->d_buf[s->last_lit] = dist; \ | 333 | s->d_buf[s->last_lit] = dist; \ |
334 | s->l_buf[s->last_lit++] = len; \ | 334 | s->l_buf[s->last_lit++] = len; \ |
335 | dist--; \ | 335 | dist--; \ |
@@ -23,14 +23,14 @@ local int gz_load(state, buf, len, have) | |||
23 | unsigned len; | 23 | unsigned len; |
24 | unsigned *have; | 24 | unsigned *have; |
25 | { | 25 | { |
26 | int ret; | 26 | ssize_t ret; |
27 | 27 | ||
28 | *have = 0; | 28 | *have = 0; |
29 | do { | 29 | do { |
30 | ret = read(state->fd, buf + *have, len - *have); | 30 | ret = read(state->fd, buf + *have, len - *have); |
31 | if (ret <= 0) | 31 | if (ret <= 0) |
32 | break; | 32 | break; |
33 | *have += ret; | 33 | *have += (unsigned)ret; |
34 | } while (*have < len); | 34 | } while (*have < len); |
35 | if (ret < 0) { | 35 | if (ret < 0) { |
36 | gz_error(state, Z_ERRNO, zstrerror()); | 36 | gz_error(state, Z_ERRNO, zstrerror()); |
@@ -451,7 +451,7 @@ int ZEXPORT gzungetc(c, file) | |||
451 | if (state->x.have == 0) { | 451 | if (state->x.have == 0) { |
452 | state->x.have = 1; | 452 | state->x.have = 1; |
453 | state->x.next = state->out + (state->size << 1) - 1; | 453 | state->x.next = state->out + (state->size << 1) - 1; |
454 | state->x.next[0] = c; | 454 | state->x.next[0] = (unsigned char)c; |
455 | state->x.pos--; | 455 | state->x.pos--; |
456 | state->past = 0; | 456 | state->past = 0; |
457 | return c; | 457 | return c; |
@@ -473,7 +473,7 @@ int ZEXPORT gzungetc(c, file) | |||
473 | } | 473 | } |
474 | state->x.have++; | 474 | state->x.have++; |
475 | state->x.next--; | 475 | state->x.next--; |
476 | state->x.next[0] = c; | 476 | state->x.next[0] = (unsigned char)c; |
477 | state->x.pos--; | 477 | state->x.pos--; |
478 | state->past = 0; | 478 | state->past = 0; |
479 | return c; | 479 | return c; |
@@ -72,7 +72,8 @@ local int gz_comp(state, flush) | |||
72 | gz_statep state; | 72 | gz_statep state; |
73 | int flush; | 73 | int flush; |
74 | { | 74 | { |
75 | int ret, got; | 75 | int ret; |
76 | ssize_t got; | ||
76 | unsigned have; | 77 | unsigned have; |
77 | z_streamp strm = &(state->strm); | 78 | z_streamp strm = &(state->strm); |
78 | 79 | ||
@@ -88,7 +89,7 @@ local int gz_comp(state, flush) | |||
88 | gz_error(state, Z_ERRNO, zstrerror()); | 89 | gz_error(state, Z_ERRNO, zstrerror()); |
89 | return -1; | 90 | return -1; |
90 | } | 91 | } |
91 | strm->avail_in -= got; | 92 | strm->avail_in -= (unsigned)got; |
92 | strm->next_in += got; | 93 | strm->next_in += got; |
93 | } | 94 | } |
94 | return 0; | 95 | return 0; |
@@ -103,7 +104,7 @@ local int gz_comp(state, flush) | |||
103 | (flush != Z_FINISH || ret == Z_STREAM_END))) { | 104 | (flush != Z_FINISH || ret == Z_STREAM_END))) { |
104 | while (strm->next_out > state->x.next) { | 105 | while (strm->next_out > state->x.next) { |
105 | got = write(state->fd, state->x.next, | 106 | got = write(state->fd, state->x.next, |
106 | strm->next_out - state->x.next); | 107 | (unsigned long)(strm->next_out - state->x.next)); |
107 | if (got < 0) { | 108 | if (got < 0) { |
108 | gz_error(state, Z_ERRNO, zstrerror()); | 109 | gz_error(state, Z_ERRNO, zstrerror()); |
109 | return -1; | 110 | return -1; |
@@ -281,7 +282,7 @@ int ZEXPORT gzputc(file, c) | |||
281 | strm->next_in = state->in; | 282 | strm->next_in = state->in; |
282 | have = (unsigned)((strm->next_in + strm->avail_in) - state->in); | 283 | have = (unsigned)((strm->next_in + strm->avail_in) - state->in); |
283 | if (have < state->size) { | 284 | if (have < state->size) { |
284 | state->in[have] = c; | 285 | state->in[have] = (unsigned char)c; |
285 | strm->avail_in++; | 286 | strm->avail_in++; |
286 | state->x.pos++; | 287 | state->x.pos++; |
287 | return c & 0xff; | 288 | return c & 0xff; |
@@ -289,7 +290,7 @@ int ZEXPORT gzputc(file, c) | |||
289 | } | 290 | } |
290 | 291 | ||
291 | /* no room in buffer or not initialized, use gz_write() */ | 292 | /* no room in buffer or not initialized, use gz_write() */ |
292 | buf[0] = c; | 293 | buf[0] = (unsigned char)c; |
293 | if (gzwrite(file, buf, 1) != 1) | 294 | if (gzwrite(file, buf, 1) != 1) |
294 | return -1; | 295 | return -1; |
295 | return c & 0xff; | 296 | return c & 0xff; |
@@ -315,7 +316,8 @@ int ZEXPORT gzputs(file, str) | |||
315 | /* -- see zlib.h -- */ | 316 | /* -- see zlib.h -- */ |
316 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | 317 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) |
317 | { | 318 | { |
318 | unsigned len, left; | 319 | int len; |
320 | unsigned left; | ||
319 | char *next; | 321 | char *next; |
320 | gz_statep state; | 322 | gz_statep state; |
321 | z_streamp strm; | 323 | z_streamp strm; |
@@ -346,7 +348,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
346 | be state->size bytes available after the current contents */ | 348 | be state->size bytes available after the current contents */ |
347 | if (strm->avail_in == 0) | 349 | if (strm->avail_in == 0) |
348 | strm->next_in = state->in; | 350 | strm->next_in = state->in; |
349 | next = (char *)(strm->next_in + strm->avail_in); | 351 | next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); |
350 | next[state->size - 1] = 0; | 352 | next[state->size - 1] = 0; |
351 | #ifdef NO_vsnprintf | 353 | #ifdef NO_vsnprintf |
352 | # ifdef HAS_vsprintf_void | 354 | # ifdef HAS_vsprintf_void |
@@ -366,11 +368,11 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
366 | #endif | 368 | #endif |
367 | 369 | ||
368 | /* check that printf() results fit in buffer */ | 370 | /* check that printf() results fit in buffer */ |
369 | if (len == 0 || len >= state->size || next[state->size - 1] != 0) | 371 | if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) |
370 | return 0; | 372 | return 0; |
371 | 373 | ||
372 | /* update buffer and position, compress first half if past that */ | 374 | /* update buffer and position, compress first half if past that */ |
373 | strm->avail_in += len; | 375 | strm->avail_in += (unsigned)len; |
374 | state->x.pos += len; | 376 | state->x.pos += len; |
375 | if (strm->avail_in >= state->size) { | 377 | if (strm->avail_in >= state->size) { |
376 | left = strm->avail_in - state->size; | 378 | left = strm->avail_in - state->size; |
@@ -381,7 +383,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
381 | strm->next_in = state->in; | 383 | strm->next_in = state->in; |
382 | strm->avail_in = left; | 384 | strm->avail_in = left; |
383 | } | 385 | } |
384 | return (int)len; | 386 | return len; |
385 | } | 387 | } |
386 | 388 | ||
387 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | 389 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) |
@@ -61,7 +61,7 @@ int stream_size; | |||
61 | Tracev((stderr, "inflate: allocated\n")); | 61 | Tracev((stderr, "inflate: allocated\n")); |
62 | strm->state = (struct internal_state FAR *)state; | 62 | strm->state = (struct internal_state FAR *)state; |
63 | state->dmax = 32768U; | 63 | state->dmax = 32768U; |
64 | state->wbits = windowBits; | 64 | state->wbits = (uInt)windowBits; |
65 | state->wsize = 1U << windowBits; | 65 | state->wsize = 1U << windowBits; |
66 | state->window = window; | 66 | state->window = window; |
67 | state->wnext = 0; | 67 | state->wnext = 0; |
@@ -241,10 +241,10 @@ int value; | |||
241 | state->bits = 0; | 241 | state->bits = 0; |
242 | return Z_OK; | 242 | return Z_OK; |
243 | } | 243 | } |
244 | if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; | 244 | if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; |
245 | value &= (1L << bits) - 1; | 245 | value &= (1L << bits) - 1; |
246 | state->hold += (unsigned)value << state->bits; | 246 | state->hold += (unsigned)value << state->bits; |
247 | state->bits += bits; | 247 | state->bits += (uInt)bits; |
248 | return Z_OK; | 248 | return Z_OK; |
249 | } | 249 | } |
250 | 250 | ||
@@ -767,7 +767,7 @@ int flush; | |||
767 | if (state->head != Z_NULL && | 767 | if (state->head != Z_NULL && |
768 | state->head->name != Z_NULL && | 768 | state->head->name != Z_NULL && |
769 | state->length < state->head->name_max) | 769 | state->length < state->head->name_max) |
770 | state->head->name[state->length++] = len; | 770 | state->head->name[state->length++] = (Bytef)len; |
771 | } while (len && copy < have); | 771 | } while (len && copy < have); |
772 | if ((state->flags & 0x0200) && (state->wrap & 4)) | 772 | if ((state->flags & 0x0200) && (state->wrap & 4)) |
773 | state->check = crc32(state->check, next, copy); | 773 | state->check = crc32(state->check, next, copy); |
@@ -788,7 +788,7 @@ int flush; | |||
788 | if (state->head != Z_NULL && | 788 | if (state->head != Z_NULL && |
789 | state->head->comment != Z_NULL && | 789 | state->head->comment != Z_NULL && |
790 | state->length < state->head->comm_max) | 790 | state->length < state->head->comm_max) |
791 | state->head->comment[state->length++] = len; | 791 | state->head->comment[state->length++] = (Bytef)len; |
792 | } while (len && copy < have); | 792 | } while (len && copy < have); |
793 | if ((state->flags & 0x0200) && (state->wrap & 4)) | 793 | if ((state->flags & 0x0200) && (state->wrap & 4)) |
794 | state->check = crc32(state->check, next, copy); | 794 | state->check = crc32(state->check, next, copy); |
@@ -1249,7 +1249,7 @@ int flush; | |||
1249 | if ((state->wrap & 4) && out) | 1249 | if ((state->wrap & 4) && out) |
1250 | strm->adler = state->check = | 1250 | strm->adler = state->check = |
1251 | UPDATE(state->check, strm->next_out - out, out); | 1251 | UPDATE(state->check, strm->next_out - out, out); |
1252 | strm->data_type = state->bits + (state->last ? 64 : 0) + | 1252 | strm->data_type = (int)state->bits + (state->last ? 64 : 0) + |
1253 | (state->mode == TYPE ? 128 : 0) + | 1253 | (state->mode == TYPE ? 128 : 0) + |
1254 | (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); | 1254 | (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); |
1255 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) | 1255 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
@@ -1500,6 +1500,7 @@ int subvert; | |||
1500 | state->sane = !subvert; | 1500 | state->sane = !subvert; |
1501 | return Z_OK; | 1501 | return Z_OK; |
1502 | #else | 1502 | #else |
1503 | (void)subvert; | ||
1503 | state->sane = 1; | 1504 | state->sane = 1; |
1504 | return Z_DATA_ERROR; | 1505 | return Z_DATA_ERROR; |
1505 | #endif | 1506 | #endif |
@@ -1537,7 +1538,7 @@ unsigned long ZEXPORT inflateCodesUsed(strm) | |||
1537 | z_streamp strm; | 1538 | z_streamp strm; |
1538 | { | 1539 | { |
1539 | struct inflate_state FAR *state; | 1540 | struct inflate_state FAR *state; |
1540 | if (strm == Z_NULL || strm->state == Z_NULL) return -1L; | 1541 | if (strm == Z_NULL || strm->state == Z_NULL) return (unsigned long)0 - 1; |
1541 | state = (struct inflate_state FAR *)strm->state; | 1542 | state = (struct inflate_state FAR *)strm->state; |
1542 | return state->next - state->codes; | 1543 | return (unsigned long)(state->next - state->codes); |
1543 | } | 1544 | } |
@@ -213,7 +213,7 @@ local void send_bits(s, value, length) | |||
213 | #define send_bits(s, value, length) \ | 213 | #define send_bits(s, value, length) \ |
214 | { int len = length;\ | 214 | { int len = length;\ |
215 | if (s->bi_valid > (int)Buf_size - len) {\ | 215 | if (s->bi_valid > (int)Buf_size - len) {\ |
216 | int val = value;\ | 216 | int val = (int)value;\ |
217 | s->bi_buf |= (ush)val << s->bi_valid;\ | 217 | s->bi_buf |= (ush)val << s->bi_valid;\ |
218 | put_short(s, s->bi_buf);\ | 218 | put_short(s, s->bi_buf);\ |
219 | s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ | 219 | s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ |
@@ -522,8 +522,8 @@ local void gen_bitlen(s, desc) | |||
522 | xbits = 0; | 522 | xbits = 0; |
523 | if (n >= base) xbits = extra[n-base]; | 523 | if (n >= base) xbits = extra[n-base]; |
524 | f = tree[n].Freq; | 524 | f = tree[n].Freq; |
525 | s->opt_len += (ulg)f * (bits + xbits); | 525 | s->opt_len += (ulg)f * (unsigned)(bits + xbits); |
526 | if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); | 526 | if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); |
527 | } | 527 | } |
528 | if (overflow == 0) return; | 528 | if (overflow == 0) return; |
529 | 529 | ||
@@ -555,8 +555,7 @@ local void gen_bitlen(s, desc) | |||
555 | if (m > max_code) continue; | 555 | if (m > max_code) continue; |
556 | if ((unsigned) tree[m].Len != (unsigned) bits) { | 556 | if ((unsigned) tree[m].Len != (unsigned) bits) { |
557 | Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); | 557 | Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); |
558 | s->opt_len += ((long)bits - (long)tree[m].Len) | 558 | s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; |
559 | *(long)tree[m].Freq; | ||
560 | tree[m].Len = (ush)bits; | 559 | tree[m].Len = (ush)bits; |
561 | } | 560 | } |
562 | n--; | 561 | n--; |
@@ -578,7 +577,7 @@ local void gen_codes (tree, max_code, bl_count) | |||
578 | ushf *bl_count; /* number of codes at each bit length */ | 577 | ushf *bl_count; /* number of codes at each bit length */ |
579 | { | 578 | { |
580 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ | 579 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ |
581 | ush code = 0; /* running code value */ | 580 | unsigned code = 0; /* running code value */ |
582 | int bits; /* bit index */ | 581 | int bits; /* bit index */ |
583 | int n; /* code index */ | 582 | int n; /* code index */ |
584 | 583 | ||
@@ -586,7 +585,8 @@ local void gen_codes (tree, max_code, bl_count) | |||
586 | * without bit reversal. | 585 | * without bit reversal. |
587 | */ | 586 | */ |
588 | for (bits = 1; bits <= MAX_BITS; bits++) { | 587 | for (bits = 1; bits <= MAX_BITS; bits++) { |
589 | next_code[bits] = code = (code + bl_count[bits-1]) << 1; | 588 | code = (code + bl_count[bits-1]) << 1; |
589 | next_code[bits] = (ush)code; | ||
590 | } | 590 | } |
591 | /* Check that the bit counts in bl_count are consistent. The last code | 591 | /* Check that the bit counts in bl_count are consistent. The last code |
592 | * must be all ones. | 592 | * must be all ones. |
@@ -599,7 +599,7 @@ local void gen_codes (tree, max_code, bl_count) | |||
599 | int len = tree[n].Len; | 599 | int len = tree[n].Len; |
600 | if (len == 0) continue; | 600 | if (len == 0) continue; |
601 | /* Now reverse the bits */ | 601 | /* Now reverse the bits */ |
602 | tree[n].Code = bi_reverse(next_code[len]++, len); | 602 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); |
603 | 603 | ||
604 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | 604 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", |
605 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); | 605 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); |
@@ -821,7 +821,7 @@ local int build_bl_tree(s) | |||
821 | if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; | 821 | if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; |
822 | } | 822 | } |
823 | /* Update opt_len to include the bit length tree and counts */ | 823 | /* Update opt_len to include the bit length tree and counts */ |
824 | s->opt_len += 3*(max_blindex+1) + 5+5+4; | 824 | s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; |
825 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", | 825 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", |
826 | s->opt_len, s->static_len)); | 826 | s->opt_len, s->static_len)); |
827 | 827 | ||
@@ -1090,7 +1090,7 @@ local void compress_block(s, ltree, dtree) | |||
1090 | send_code(s, code, dtree); /* send the distance code */ | 1090 | send_code(s, code, dtree); /* send the distance code */ |
1091 | extra = extra_dbits[code]; | 1091 | extra = extra_dbits[code]; |
1092 | if (extra != 0) { | 1092 | if (extra != 0) { |
1093 | dist -= base_dist[code]; | 1093 | dist -= (unsigned)base_dist[code]; |
1094 | send_bits(s, dist, extra); /* send the extra distance bits */ | 1094 | send_bits(s, dist, extra); /* send the extra distance bits */ |
1095 | } | 1095 | } |
1096 | } /* literal or match pair ? */ | 1096 | } /* literal or match pair ? */ |
@@ -1765,6 +1765,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); | |||
1765 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); | 1765 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); |
1766 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); | 1766 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); |
1767 | ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); | 1767 | ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); |
1768 | ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); | ||
1768 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); | 1769 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); |
1769 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | 1770 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); |
1770 | #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) | 1771 | #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) |
@@ -11,16 +11,17 @@ | |||
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | z_const char * const z_errmsg[10] = { | 13 | z_const char * const z_errmsg[10] = { |
14 | "need dictionary", /* Z_NEED_DICT 2 */ | 14 | (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ |
15 | "stream end", /* Z_STREAM_END 1 */ | 15 | (z_const char *)"stream end", /* Z_STREAM_END 1 */ |
16 | "", /* Z_OK 0 */ | 16 | (z_const char *)"", /* Z_OK 0 */ |
17 | "file error", /* Z_ERRNO (-1) */ | 17 | (z_const char *)"file error", /* Z_ERRNO (-1) */ |
18 | "stream error", /* Z_STREAM_ERROR (-2) */ | 18 | (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ |
19 | "data error", /* Z_DATA_ERROR (-3) */ | 19 | (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ |
20 | "insufficient memory", /* Z_MEM_ERROR (-4) */ | 20 | (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ |
21 | "buffer error", /* Z_BUF_ERROR (-5) */ | 21 | (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ |
22 | "incompatible version",/* Z_VERSION_ERROR (-6) */ | 22 | (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
23 | ""}; | 23 | (z_const char *)"" |
24 | }; | ||
24 | 25 | ||
25 | 26 | ||
26 | const char * ZEXPORT zlibVersion() | 27 | const char * ZEXPORT zlibVersion() |