code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
+ static const uint16_t order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/* Check that the strm exists and that the state was initialized */
state->have = 0;
while (state->have < state->ncode) {
NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
+ state->lens[order[state->have++]] = (uint16_t)BITS(3);
DROPBITS(3);
}
while (state->have < 19)
break;
}
while (copy--)
- state->lens[state->have++] = (unsigned short)len;
+ state->lens[state->have++] = (uint16_t)len;
}
}
#ifdef GUNZIP
unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
#endif
- static const unsigned short order[19] = /* permutation of code lengths */
+ static const uint16_t order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
case LENLENS:
while (state->have < state->ncode) {
NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
+ state->lens[order[state->have++]] = (uint16_t)BITS(3);
DROPBITS(3);
}
while (state->have < 19)
break;
}
while (copy--)
- state->lens[state->have++] = (unsigned short)len;
+ state->lens[state->have++] = (uint16_t)len;
}
}
unsigned nlen; /* number of length code lengths */
unsigned ndist; /* number of distance code lengths */
unsigned have; /* number of code lengths in lens[] */
- code *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
+ 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 */
code codes[ENOUGH]; /* space for code tables */
int sane; /* if false, allow invalid distance too far */
int back; /* bits back of last unprocessed length/lit */
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
-int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned codes,
- code * *table, unsigned *bits, unsigned short *work)
+int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
+ code * *table, unsigned *bits, uint16_t *work)
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
code here; /* table entry for duplication */
- code *next; /* next available space in table */
- const unsigned short *base; /* base value table to use */
- const unsigned short *extra; /* extra bits table to use */
+ code *next; /* next available space in table */
+ const uint16_t *base; /* base value table to use */
+ const uint16_t *extra; /* extra bits table to use */
int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
+ uint16_t count[MAXBITS+1]; /* number of codes of each length */
+ uint16_t offs[MAXBITS+1]; /* offsets in table for each length */
+ static const uint16_t lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
+ static const uint16_t lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
+ static const uint16_t dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
+ static const uint16_t dext[32] = { /* Distance codes 0..29 extra */
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
28, 28, 29, 29, 64, 64};
if (max == 0) { /* no symbols to code at all */
here.op = (unsigned char)64; /* invalid code marker */
here.bits = (unsigned char)1;
- here.val = (unsigned short)0;
+ here.val = (uint16_t)0;
*(*table)++ = here; /* make a table to force an error */
*(*table)++ = here;
*bits = 1;
/* sort symbols by length, by symbol order within each length */
for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
+ if (lens[sym] != 0) work[offs[lens[sym]]++] = (uint16_t)sym;
/*
Create and fill in decoding tables. In this loop, the table being
low = huff & mask;
(*table)[low].op = (unsigned char)curr;
(*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
+ (*table)[low].val = (uint16_t)(next - *table);
}
}
if (huff != 0) {
here.op = (unsigned char)64; /* invalid code marker */
here.bits = (unsigned char)(len - drop);
- here.val = (unsigned short)0;
+ here.val = (uint16_t)0;
next[huff] = here;
}
of a literal, the base length or distance, or the offset from
the current table to the next table. Each entry is four bytes. */
typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
+ unsigned char op; /* operation, extra bits, table bits */
+ unsigned char bits; /* bits in this part of the code */
+ uint16_t val; /* offset in table or code value */
} code;
/* op values as set by inflate_table():
DISTS
} codetype;
-int ZLIB_INTERNAL inflate_table (codetype type, unsigned short *lens,
- unsigned codes, code * *table,
- unsigned *bits, unsigned short *work);
+int ZLIB_INTERNAL inflate_table (codetype type, uint16_t *lens, unsigned codes,
+ code * *table, unsigned *bits, uint16_t *work);
const unsigned wmask = s->w_mask;
const Pos *prev = s->prev;
- unsigned short scan_start, scan_end;
+ uint16_t scan_start, scan_end;
unsigned chain_length;
IPos limit;
unsigned int len, best_len, nice_match;
scan = s->window + s->strstart;
strend = s->window + s->strstart + MAX_MATCH - 1;
- scan_start = *(unsigned short *)scan;
- scan_end = *(unsigned short *)(scan + best_len-1);
+ scan_start = *(uint16_t *)scan;
+ scan_end = *(uint16_t *)(scan + best_len-1);
Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD,
"need lookahead");
* is limited to the lookahead, so the output of deflate is not
* affected by the uninitialized values.
*/
- if (likely((*(unsigned short *)(match + best_len - 1) != scan_end)))
+ if (likely((*(uint16_t *)(match + best_len - 1) != scan_end)))
continue;
- if (*(unsigned short *)match != scan_start)
+ if (*(uint16_t *)match != scan_start)
continue;
/* It is not necessary to compare scan[2] and match[2] since
match++;
do {
- } while (*(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
- *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
- *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
- *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
+ } while (*(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+ *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+ *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+ *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
scan < strend);
/*
best_len = len;
if (len >= nice_match)
break;
- scan_end = *(unsigned short *)(scan + best_len - 1);
+ scan_end = *(uint16_t *)(scan + best_len - 1);
} else {
/*
* The probability of finding a match later if we here
uInt wmask = s->w_mask;
register unsigned char *strend = s->window + s->strstart + MAX_MATCH;
- register unsigned short scan_start = *(unsigned short*)scan;
- register unsigned short scan_end = *(unsigned short*)(scan+best_len-1);
+ register uint16_t scan_start = *(uint16_t*)scan;
+ register uint16_t scan_end = *(uint16_t*)(scan+best_len-1);
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
* It is easy to get rid of this optimization if necessary.
int cont = 1;
do {
match = win + cur_match;
- if (likely(*(unsigned short*)(match+best_len-1) != scan_end)) {
+ if (likely(*(uint16_t*)(match+best_len-1) != scan_end)) {
if ((cur_match = prev[cur_match & wmask]) > limit
&& --chain_length != 0) {
continue;
if (!cont)
break;
- if (*(unsigned short*)match != scan_start)
+ if (*(uint16_t*)match != scan_start)
continue;
/* It is not necessary to compare scan[2] and match[2] since they are
s->match_start = cur_match;
best_len = len;
if (len >= nice_match) break;
- scan_end = *(unsigned short*)(scan+best_len-1);
+ scan_end = *(uint16_t*)(scan+best_len-1);
} else {
/*
* The probability of finding a match later if we here
{
int ret;
unsigned bits;
- unsigned short lens[16], work[16];
+ uint16_t lens[16], work[16];
code *next, table[ENOUGH_DISTS];
/* we need to call inflate_table() directly in order to manifest not-
enough errors, since zlib insures that enough is always enough */
for (bits = 0; bits < 15; bits++)
- lens[bits] = (unsigned short)(bits + 1);
+ lens[bits] = (uint16_t)(bits + 1);
lens[15] = 15;
next = table;
bits = 15;