Clean up type conversions.
This commit is contained in:
parent
2edb94a302
commit
7096424f23
24
deflate.c
24
deflate.c
@ -84,7 +84,7 @@ local block_state deflate_huff OF((deflate_state *s, int flush));
|
|||||||
local void lm_init OF((deflate_state *s));
|
local void lm_init OF((deflate_state *s));
|
||||||
local void putShortMSB OF((deflate_state *s, uInt b));
|
local void putShortMSB OF((deflate_state *s, uInt b));
|
||||||
local void flush_pending OF((z_streamp strm));
|
local void flush_pending OF((z_streamp strm));
|
||||||
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
||||||
#ifdef ASMV
|
#ifdef ASMV
|
||||||
void match_init OF((void)); /* asm code initialization */
|
void match_init OF((void)); /* asm code initialization */
|
||||||
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||||
@ -277,11 +277,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|||||||
|
|
||||||
s->wrap = wrap;
|
s->wrap = wrap;
|
||||||
s->gzhead = Z_NULL;
|
s->gzhead = Z_NULL;
|
||||||
s->w_bits = windowBits;
|
s->w_bits = (uInt)windowBits;
|
||||||
s->w_size = 1 << s->w_bits;
|
s->w_size = 1 << s->w_bits;
|
||||||
s->w_mask = s->w_size - 1;
|
s->w_mask = s->w_size - 1;
|
||||||
|
|
||||||
s->hash_bits = memLevel + 7;
|
s->hash_bits = (uInt)memLevel + 7;
|
||||||
s->hash_size = 1 << s->hash_bits;
|
s->hash_size = 1 << s->hash_bits;
|
||||||
s->hash_mask = s->hash_size - 1;
|
s->hash_mask = s->hash_size - 1;
|
||||||
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
|
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)
|
|||||||
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
s = strm->state;
|
s = strm->state;
|
||||||
s->good_match = good_length;
|
s->good_match = (uInt)good_length;
|
||||||
s->max_lazy_match = max_lazy;
|
s->max_lazy_match = (uInt)max_lazy;
|
||||||
s->nice_match = nice_length;
|
s->nice_match = nice_length;
|
||||||
s->max_chain_length = max_chain;
|
s->max_chain_length = (uInt)max_chain;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1068,7 +1068,7 @@ int ZEXPORT deflateCopy (dest, source)
|
|||||||
* allocating a large strm->next_in buffer and copying from it.
|
* allocating a large strm->next_in buffer and copying from it.
|
||||||
* (See also flush_pending()).
|
* (See also flush_pending()).
|
||||||
*/
|
*/
|
||||||
local int read_buf(strm, buf, size)
|
local unsigned read_buf(strm, buf, size)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
Bytef *buf;
|
Bytef *buf;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
@ -1092,7 +1092,7 @@ local int read_buf(strm, buf, size)
|
|||||||
strm->next_in += len;
|
strm->next_in += len;
|
||||||
strm->total_in += len;
|
strm->total_in += len;
|
||||||
|
|
||||||
return (int)len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
@ -1148,7 +1148,7 @@ local uInt longest_match(s, cur_match)
|
|||||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||||
register Bytef *match; /* matched string */
|
register Bytef *match; /* matched string */
|
||||||
register int len; /* length of current match */
|
register int len; /* length of current match */
|
||||||
int best_len = s->prev_length; /* best match length so far */
|
int best_len = (int)s->prev_length; /* best match length so far */
|
||||||
int nice_match = s->nice_match; /* stop if match long enough */
|
int nice_match = s->nice_match; /* stop if match long enough */
|
||||||
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
|
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
|
||||||
s->strstart - (IPos)MAX_DIST(s) : NIL;
|
s->strstart - (IPos)MAX_DIST(s) : NIL;
|
||||||
@ -1183,7 +1183,7 @@ local uInt longest_match(s, cur_match)
|
|||||||
/* Do not look for matches beyond the end of the input. This is necessary
|
/* Do not look for matches beyond the end of the input. This is necessary
|
||||||
* to make deflate deterministic.
|
* to make deflate deterministic.
|
||||||
*/
|
*/
|
||||||
if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
|
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
||||||
|
|
||||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
||||||
|
|
||||||
@ -1589,7 +1589,7 @@ local block_state deflate_stored(s, flush)
|
|||||||
s->lookahead = 0;
|
s->lookahead = 0;
|
||||||
|
|
||||||
/* Emit a stored block if pending_buf will be full: */
|
/* Emit a stored block if pending_buf will be full: */
|
||||||
max_start = s->block_start + max_block_size;
|
max_start = max_block_size + (ulg)s->block_start;
|
||||||
if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
|
if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
|
||||||
/* strstart == 0 is possible when wraparound on 16-bit machine */
|
/* strstart == 0 is possible when wraparound on 16-bit machine */
|
||||||
s->lookahead = (uInt)(s->strstart - max_start);
|
s->lookahead = (uInt)(s->strstart - max_start);
|
||||||
@ -1887,7 +1887,7 @@ local block_state deflate_rle(s, flush)
|
|||||||
prev == *++scan && prev == *++scan &&
|
prev == *++scan && prev == *++scan &&
|
||||||
prev == *++scan && prev == *++scan &&
|
prev == *++scan && prev == *++scan &&
|
||||||
scan < strend);
|
scan < strend);
|
||||||
s->match_length = MAX_MATCH - (int)(strend - scan);
|
s->match_length = MAX_MATCH - (uInt)(strend - scan);
|
||||||
if (s->match_length > s->lookahead)
|
if (s->match_length > s->lookahead)
|
||||||
s->match_length = s->lookahead;
|
s->match_length = s->lookahead;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ typedef struct internal_state {
|
|||||||
/* Output a byte on the stream.
|
/* Output a byte on the stream.
|
||||||
* IN assertion: there is enough room in pending_buf.
|
* IN assertion: there is enough room in pending_buf.
|
||||||
*/
|
*/
|
||||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
|
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
|
||||||
|
|
||||||
|
|
||||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||||
@ -328,8 +328,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
|||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||||
}
|
}
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
{ uch len = (length); \
|
{ uch len = (uch)(length); \
|
||||||
ush dist = (distance); \
|
ush dist = (ush)(distance); \
|
||||||
s->d_buf[s->last_lit] = dist; \
|
s->d_buf[s->last_lit] = dist; \
|
||||||
s->l_buf[s->last_lit++] = len; \
|
s->l_buf[s->last_lit++] = len; \
|
||||||
dist--; \
|
dist--; \
|
||||||
|
8
gzread.c
8
gzread.c
@ -23,14 +23,14 @@ local int gz_load(state, buf, len, have)
|
|||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned *have;
|
unsigned *have;
|
||||||
{
|
{
|
||||||
int ret;
|
ssize_t ret;
|
||||||
|
|
||||||
*have = 0;
|
*have = 0;
|
||||||
do {
|
do {
|
||||||
ret = read(state->fd, buf + *have, len - *have);
|
ret = read(state->fd, buf + *have, len - *have);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
break;
|
break;
|
||||||
*have += ret;
|
*have += (unsigned)ret;
|
||||||
} while (*have < len);
|
} while (*have < len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
gz_error(state, Z_ERRNO, zstrerror());
|
gz_error(state, Z_ERRNO, zstrerror());
|
||||||
@ -451,7 +451,7 @@ int ZEXPORT gzungetc(c, file)
|
|||||||
if (state->x.have == 0) {
|
if (state->x.have == 0) {
|
||||||
state->x.have = 1;
|
state->x.have = 1;
|
||||||
state->x.next = state->out + (state->size << 1) - 1;
|
state->x.next = state->out + (state->size << 1) - 1;
|
||||||
state->x.next[0] = c;
|
state->x.next[0] = (unsigned char)c;
|
||||||
state->x.pos--;
|
state->x.pos--;
|
||||||
state->past = 0;
|
state->past = 0;
|
||||||
return c;
|
return c;
|
||||||
@ -473,7 +473,7 @@ int ZEXPORT gzungetc(c, file)
|
|||||||
}
|
}
|
||||||
state->x.have++;
|
state->x.have++;
|
||||||
state->x.next--;
|
state->x.next--;
|
||||||
state->x.next[0] = c;
|
state->x.next[0] = (unsigned char)c;
|
||||||
state->x.pos--;
|
state->x.pos--;
|
||||||
state->past = 0;
|
state->past = 0;
|
||||||
return c;
|
return c;
|
||||||
|
22
gzwrite.c
22
gzwrite.c
@ -72,7 +72,8 @@ local int gz_comp(state, flush)
|
|||||||
gz_statep state;
|
gz_statep state;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
int ret, got;
|
int ret;
|
||||||
|
ssize_t got;
|
||||||
unsigned have;
|
unsigned have;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ local int gz_comp(state, flush)
|
|||||||
gz_error(state, Z_ERRNO, zstrerror());
|
gz_error(state, Z_ERRNO, zstrerror());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strm->avail_in -= got;
|
strm->avail_in -= (unsigned)got;
|
||||||
strm->next_in += got;
|
strm->next_in += got;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -103,7 +104,7 @@ local int gz_comp(state, flush)
|
|||||||
(flush != Z_FINISH || ret == Z_STREAM_END))) {
|
(flush != Z_FINISH || ret == Z_STREAM_END))) {
|
||||||
while (strm->next_out > state->x.next) {
|
while (strm->next_out > state->x.next) {
|
||||||
got = write(state->fd, state->x.next,
|
got = write(state->fd, state->x.next,
|
||||||
strm->next_out - state->x.next);
|
(unsigned long)(strm->next_out - state->x.next));
|
||||||
if (got < 0) {
|
if (got < 0) {
|
||||||
gz_error(state, Z_ERRNO, zstrerror());
|
gz_error(state, Z_ERRNO, zstrerror());
|
||||||
return -1;
|
return -1;
|
||||||
@ -281,7 +282,7 @@ int ZEXPORT gzputc(file, c)
|
|||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
|
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
|
||||||
if (have < state->size) {
|
if (have < state->size) {
|
||||||
state->in[have] = c;
|
state->in[have] = (unsigned char)c;
|
||||||
strm->avail_in++;
|
strm->avail_in++;
|
||||||
state->x.pos++;
|
state->x.pos++;
|
||||||
return c & 0xff;
|
return c & 0xff;
|
||||||
@ -289,7 +290,7 @@ int ZEXPORT gzputc(file, c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* no room in buffer or not initialized, use gz_write() */
|
/* no room in buffer or not initialized, use gz_write() */
|
||||||
buf[0] = c;
|
buf[0] = (unsigned char)c;
|
||||||
if (gzwrite(file, buf, 1) != 1)
|
if (gzwrite(file, buf, 1) != 1)
|
||||||
return -1;
|
return -1;
|
||||||
return c & 0xff;
|
return c & 0xff;
|
||||||
@ -315,7 +316,8 @@ int ZEXPORT gzputs(file, str)
|
|||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
||||||
{
|
{
|
||||||
unsigned len, left;
|
int len;
|
||||||
|
unsigned left;
|
||||||
char *next;
|
char *next;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
@ -346,7 +348,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
|||||||
be state->size bytes available after the current contents */
|
be state->size bytes available after the current contents */
|
||||||
if (strm->avail_in == 0)
|
if (strm->avail_in == 0)
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
next = (char *)(strm->next_in + strm->avail_in);
|
next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
|
||||||
next[state->size - 1] = 0;
|
next[state->size - 1] = 0;
|
||||||
#ifdef NO_vsnprintf
|
#ifdef NO_vsnprintf
|
||||||
# ifdef HAS_vsprintf_void
|
# ifdef HAS_vsprintf_void
|
||||||
@ -366,11 +368,11 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check that printf() results fit in buffer */
|
/* check that printf() results fit in buffer */
|
||||||
if (len == 0 || len >= state->size || next[state->size - 1] != 0)
|
if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* update buffer and position, compress first half if past that */
|
/* update buffer and position, compress first half if past that */
|
||||||
strm->avail_in += len;
|
strm->avail_in += (unsigned)len;
|
||||||
state->x.pos += len;
|
state->x.pos += len;
|
||||||
if (strm->avail_in >= state->size) {
|
if (strm->avail_in >= state->size) {
|
||||||
left = strm->avail_in - state->size;
|
left = strm->avail_in - state->size;
|
||||||
@ -381,7 +383,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
|||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->avail_in = left;
|
strm->avail_in = left;
|
||||||
}
|
}
|
||||||
return (int)len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
||||||
|
@ -61,7 +61,7 @@ int stream_size;
|
|||||||
Tracev((stderr, "inflate: allocated\n"));
|
Tracev((stderr, "inflate: allocated\n"));
|
||||||
strm->state = (struct internal_state FAR *)state;
|
strm->state = (struct internal_state FAR *)state;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->wbits = windowBits;
|
state->wbits = (uInt)windowBits;
|
||||||
state->wsize = 1U << windowBits;
|
state->wsize = 1U << windowBits;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
state->wnext = 0;
|
state->wnext = 0;
|
||||||
|
15
inflate.c
15
inflate.c
@ -241,10 +241,10 @@ int value;
|
|||||||
state->bits = 0;
|
state->bits = 0;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
|
if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
|
||||||
value &= (1L << bits) - 1;
|
value &= (1L << bits) - 1;
|
||||||
state->hold += (unsigned)value << state->bits;
|
state->hold += (unsigned)value << state->bits;
|
||||||
state->bits += bits;
|
state->bits += (uInt)bits;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,7 +767,7 @@ int flush;
|
|||||||
if (state->head != Z_NULL &&
|
if (state->head != Z_NULL &&
|
||||||
state->head->name != Z_NULL &&
|
state->head->name != Z_NULL &&
|
||||||
state->length < state->head->name_max)
|
state->length < state->head->name_max)
|
||||||
state->head->name[state->length++] = len;
|
state->head->name[state->length++] = (Bytef)len;
|
||||||
} while (len && copy < have);
|
} while (len && copy < have);
|
||||||
if ((state->flags & 0x0200) && (state->wrap & 4))
|
if ((state->flags & 0x0200) && (state->wrap & 4))
|
||||||
state->check = crc32(state->check, next, copy);
|
state->check = crc32(state->check, next, copy);
|
||||||
@ -788,7 +788,7 @@ int flush;
|
|||||||
if (state->head != Z_NULL &&
|
if (state->head != Z_NULL &&
|
||||||
state->head->comment != Z_NULL &&
|
state->head->comment != Z_NULL &&
|
||||||
state->length < state->head->comm_max)
|
state->length < state->head->comm_max)
|
||||||
state->head->comment[state->length++] = len;
|
state->head->comment[state->length++] = (Bytef)len;
|
||||||
} while (len && copy < have);
|
} while (len && copy < have);
|
||||||
if ((state->flags & 0x0200) && (state->wrap & 4))
|
if ((state->flags & 0x0200) && (state->wrap & 4))
|
||||||
state->check = crc32(state->check, next, copy);
|
state->check = crc32(state->check, next, copy);
|
||||||
@ -1249,7 +1249,7 @@ int flush;
|
|||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, strm->next_out - out, out);
|
UPDATE(state->check, strm->next_out - out, out);
|
||||||
strm->data_type = state->bits + (state->last ? 64 : 0) +
|
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
||||||
(state->mode == TYPE ? 128 : 0) +
|
(state->mode == TYPE ? 128 : 0) +
|
||||||
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||||
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
|
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
|
||||||
@ -1500,6 +1500,7 @@ int subvert;
|
|||||||
state->sane = !subvert;
|
state->sane = !subvert;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
#else
|
#else
|
||||||
|
(void)subvert;
|
||||||
state->sane = 1;
|
state->sane = 1;
|
||||||
return Z_DATA_ERROR;
|
return Z_DATA_ERROR;
|
||||||
#endif
|
#endif
|
||||||
@ -1537,7 +1538,7 @@ unsigned long ZEXPORT inflateCodesUsed(strm)
|
|||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL) return -1L;
|
if (strm == Z_NULL || strm->state == Z_NULL) return (unsigned long)0 - 1;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
return state->next - state->codes;
|
return (unsigned long)(state->next - state->codes);
|
||||||
}
|
}
|
||||||
|
20
trees.c
20
trees.c
@ -213,7 +213,7 @@ local void send_bits(s, value, length)
|
|||||||
#define send_bits(s, value, length) \
|
#define send_bits(s, value, length) \
|
||||||
{ int len = length;\
|
{ int len = length;\
|
||||||
if (s->bi_valid > (int)Buf_size - len) {\
|
if (s->bi_valid > (int)Buf_size - len) {\
|
||||||
int val = value;\
|
int val = (int)value;\
|
||||||
s->bi_buf |= (ush)val << s->bi_valid;\
|
s->bi_buf |= (ush)val << s->bi_valid;\
|
||||||
put_short(s, s->bi_buf);\
|
put_short(s, s->bi_buf);\
|
||||||
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
|
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
|
||||||
@ -522,8 +522,8 @@ local void gen_bitlen(s, desc)
|
|||||||
xbits = 0;
|
xbits = 0;
|
||||||
if (n >= base) xbits = extra[n-base];
|
if (n >= base) xbits = extra[n-base];
|
||||||
f = tree[n].Freq;
|
f = tree[n].Freq;
|
||||||
s->opt_len += (ulg)f * (bits + xbits);
|
s->opt_len += (ulg)f * (unsigned)(bits + xbits);
|
||||||
if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
|
if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
|
||||||
}
|
}
|
||||||
if (overflow == 0) return;
|
if (overflow == 0) return;
|
||||||
|
|
||||||
@ -555,8 +555,7 @@ local void gen_bitlen(s, desc)
|
|||||||
if (m > max_code) continue;
|
if (m > max_code) continue;
|
||||||
if ((unsigned) tree[m].Len != (unsigned) bits) {
|
if ((unsigned) tree[m].Len != (unsigned) bits) {
|
||||||
Trace((stderr,"code %d bits %d->%d\n", m, 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)
|
s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;
|
||||||
*(long)tree[m].Freq;
|
|
||||||
tree[m].Len = (ush)bits;
|
tree[m].Len = (ush)bits;
|
||||||
}
|
}
|
||||||
n--;
|
n--;
|
||||||
@ -578,7 +577,7 @@ local void gen_codes (tree, max_code, bl_count)
|
|||||||
ushf *bl_count; /* number of codes at each bit length */
|
ushf *bl_count; /* number of codes at each bit length */
|
||||||
{
|
{
|
||||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||||
ush code = 0; /* running code value */
|
unsigned code = 0; /* running code value */
|
||||||
int bits; /* bit index */
|
int bits; /* bit index */
|
||||||
int n; /* code index */
|
int n; /* code index */
|
||||||
|
|
||||||
@ -586,7 +585,8 @@ local void gen_codes (tree, max_code, bl_count)
|
|||||||
* without bit reversal.
|
* without bit reversal.
|
||||||
*/
|
*/
|
||||||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||||||
next_code[bits] = code = (code + bl_count[bits-1]) << 1;
|
code = (code + bl_count[bits-1]) << 1;
|
||||||
|
next_code[bits] = (ush)code;
|
||||||
}
|
}
|
||||||
/* Check that the bit counts in bl_count are consistent. The last code
|
/* Check that the bit counts in bl_count are consistent. The last code
|
||||||
* must be all ones.
|
* must be all ones.
|
||||||
@ -599,7 +599,7 @@ local void gen_codes (tree, max_code, bl_count)
|
|||||||
int len = tree[n].Len;
|
int len = tree[n].Len;
|
||||||
if (len == 0) continue;
|
if (len == 0) continue;
|
||||||
/* Now reverse the bits */
|
/* Now reverse the bits */
|
||||||
tree[n].Code = bi_reverse(next_code[len]++, len);
|
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||||
|
|
||||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
||||||
@ -821,7 +821,7 @@ local int build_bl_tree(s)
|
|||||||
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
||||||
}
|
}
|
||||||
/* Update opt_len to include the bit length tree and counts */
|
/* Update opt_len to include the bit length tree and counts */
|
||||||
s->opt_len += 3*(max_blindex+1) + 5+5+4;
|
s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
|
||||||
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
||||||
s->opt_len, s->static_len));
|
s->opt_len, s->static_len));
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ local void compress_block(s, ltree, dtree)
|
|||||||
send_code(s, code, dtree); /* send the distance code */
|
send_code(s, code, dtree); /* send the distance code */
|
||||||
extra = extra_dbits[code];
|
extra = extra_dbits[code];
|
||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
dist -= base_dist[code];
|
dist -= (unsigned)base_dist[code];
|
||||||
send_bits(s, dist, extra); /* send the extra distance bits */
|
send_bits(s, dist, extra); /* send the extra distance bits */
|
||||||
}
|
}
|
||||||
} /* literal or match pair ? */
|
} /* literal or match pair ? */
|
||||||
|
1
zlib.h
1
zlib.h
@ -1765,6 +1765,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
|||||||
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
|
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
|
||||||
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
||||||
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
|
||||||
|
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
|
||||||
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
||||||
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
||||||
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
|
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
|
||||||
|
21
zutil.c
21
zutil.c
@ -11,16 +11,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
z_const char * const z_errmsg[10] = {
|
z_const char * const z_errmsg[10] = {
|
||||||
"need dictionary", /* Z_NEED_DICT 2 */
|
(z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
|
||||||
"stream end", /* Z_STREAM_END 1 */
|
(z_const char *)"stream end", /* Z_STREAM_END 1 */
|
||||||
"", /* Z_OK 0 */
|
(z_const char *)"", /* Z_OK 0 */
|
||||||
"file error", /* Z_ERRNO (-1) */
|
(z_const char *)"file error", /* Z_ERRNO (-1) */
|
||||||
"stream error", /* Z_STREAM_ERROR (-2) */
|
(z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
|
||||||
"data error", /* Z_DATA_ERROR (-3) */
|
(z_const char *)"data error", /* Z_DATA_ERROR (-3) */
|
||||||
"insufficient memory", /* Z_MEM_ERROR (-4) */
|
(z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
|
||||||
"buffer error", /* Z_BUF_ERROR (-5) */
|
(z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
|
||||||
"incompatible version",/* Z_VERSION_ERROR (-6) */
|
(z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
|
||||||
""};
|
(z_const char *)""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const char * ZEXPORT zlibVersion()
|
const char * ZEXPORT zlibVersion()
|
||||||
|
Loading…
Reference in New Issue
Block a user