/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
- const Bytef *buf;
+ const Byte *buf;
uInt len;
{
unsigned long sum2;
#include <immintrin.h>
#include "deflate.h"
-extern int read_buf (z_streamp strm, Bytef *buf, unsigned size);
+extern int read_buf (z_streamp strm, Byte *buf, unsigned size);
ZLIB_INTERNAL void fill_window_sse(deflate_state *s)
{
z_const __m128i xmm_wsize = _mm_set1_epi16(s->w_size);
register unsigned n;
- register Posf *p;
+ register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
+ Byte *dest;
+ uLong *destLen;
+ const Byte *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
- stream.next_in = (z_const Bytef *)source;
+ stream.next_in = (z_const Byte *)source;
stream.avail_in = (uInt)sourceLen;
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
+ Byte *dest;
+ uLong *destLen;
+ const Byte *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
#endif
}
-ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size)
+ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Byte *dst, long size)
{
#ifdef X86_PCLMULQDQ_CRC
if (x86_cpu_has_pclmulqdq) {
local void lm_init (deflate_state *s);
local void putShortMSB (deflate_state *s, uInt b);
ZLIB_INTERNAL void flush_pending (z_streamp strm);
-ZLIB_INTERNAL int read_buf (z_streamp strm, Bytef *buf, unsigned size);
+ZLIB_INTERNAL int read_buf (z_streamp strm, Byte *buf, unsigned size);
#ifdef ASMV
void match_init (void); /* asm code initialization */
uInt longest_match (deflate_state *s, IPos cur_match);
extern void crc_reset(deflate_state *const s);
extern void crc_finalize(deflate_state *const s);
-extern void copy_with_crc(z_streamp strm, Bytef *dst, long size);
+extern void copy_with_crc(z_streamp strm, Byte *dst, long size);
/* ===========================================================================
* Local data
*/
#define CLEAR_HASH(s) \
s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+ zmemzero((Byte *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
/* ========================================================================= */
int ZEXPORT deflateInit_(strm, level, version, stream_size)
int wrap = 1;
static const char my_version[] = ZLIB_VERSION;
- ushf *overlay;
+ ush *overlay;
/* We overlay pending_buf and d_buf+l_buf. This works since the average
* output size for (length,distance) codes is <= 24 bits.
*/
window_padding = 8;
#endif
- s->window = (Bytef *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
+ s->window = (Byte *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(Byte));
+ s->prev = (Pos *) ZALLOC(strm, s->w_size, sizeof(Pos));
+ s->head = (Pos *) ZALLOC(strm, s->hash_size, sizeof(Pos));
s->high_water = 0; /* nothing written to s->window yet */
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
+ overlay = (ush *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
+ s->pending_buf = (uch *) overlay;
s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
/* ========================================================================= */
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
z_streamp strm;
- const Bytef *dictionary;
+ const Byte *dictionary;
uInt dictLength;
{
deflate_state *s;
avail = strm->avail_in;
next = strm->next_in;
strm->avail_in = dictLength;
- strm->next_in = (z_const Bytef *)dictionary;
+ strm->next_in = (z_const Byte *)dictionary;
fill_window(s);
while (s->lookahead >= MIN_MATCH) {
str = s->strstart;
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
s = strm->state;
- if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
+ if ((Byte *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
return Z_BUF_ERROR;
do {
put = Buf_size - s->bi_valid;
{
deflate_state *s;
uLong complen, wraplen;
- Bytef *str;
+ Byte *str;
/* conservative upper bound for compressed data */
complen = sourceLen +
{
deflate_state *ds;
deflate_state *ss;
- ushf *overlay;
+ ush *overlay;
if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
ds->strm = dest;
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
+ ds->window = (Byte *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
+ ds->prev = (Pos *) ZALLOC(dest, ds->w_size, sizeof(Pos));
+ ds->head = (Pos *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
+ overlay = (ush *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
+ ds->pending_buf = (uch *) overlay;
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
ds->pending_buf == Z_NULL) {
*/
ZLIB_INTERNAL int read_buf(strm, buf, size)
z_streamp strm;
- Bytef *buf;
+ Byte *buf;
unsigned size;
{
unsigned len = strm->avail_in;
deflate_state *s;
{
register unsigned n;
- register Posf *p;
+ register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
*/
#define FLUSH_BLOCK_ONLY(s, last) { \
_tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
+ (char *)&s->window[(unsigned)s->block_start] : \
+ (char *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
(last)); \
s->block_start = s->strstart; \
{
int bflush; /* set if current block must be flushed */
uInt prev; /* byte at distance one to match */
- Bytef *scan, *strend; /* scan goes up to strend for length of run */
+ Byte *scan, *strend; /* scan goes up to strend for length of run */
for (;;) {
/* Make sure that we always have enough lookahead, except
} tree_desc;
typedef ush Pos;
-typedef Pos Posf;
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
+ Byte *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
+ Byte *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 w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
- Bytef *window;
+ Byte *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* is directly used as sliding window.
*/
- Posf *prev;
+ Pos *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
- Posf *head; /* Heads of the hash chains or NIL. */
+ 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 */
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
- uchf *l_buf; /* buffer for literals or lengths */
+ uch *l_buf; /* buffer for literals or lengths */
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
uInt last_lit; /* running index in l_buf */
- ushf *d_buf;
+ ush *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
/* 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, charf *buf, ulg stored_len, int last);
+void ZLIB_INTERNAL _tr_flush_block (deflate_state *s, char *buf, ulg 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, charf *buf, ulg stored_len, int last);
+void ZLIB_INTERNAL _tr_stored_block (deflate_state *s, char *buf, ulg stored_len, int last);
void ZLIB_INTERNAL bi_windup (deflate_state *s);
#define d_code(dist) \
/* directly compress user buffer to file */
strm->avail_in = len;
- strm->next_in = (z_const Bytef *)buf;
+ strm->next_in = (z_const Byte *)buf;
state->x.pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
*/
local int updatewindow(strm, end, copy)
z_streamp strm;
-const Bytef *end;
+const Byte *end;
unsigned copy;
{
struct inflate_state *state;
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
z_streamp strm;
-Bytef *dictionary;
+Byte *dictionary;
uInt *dictLength;
{
struct inflate_state *state;
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
z_streamp strm;
-const Bytef *dictionary;
+const Byte *dictionary;
uInt dictLength;
{
struct inflate_state *state;
local unsigned std1_longest_match(deflate_state *z_const s, IPos cur_match)
{
z_const unsigned wmask = s->w_mask;
- z_const Posf *prev = s->prev;
+ z_const Pos *prev = s->prev;
unsigned chain_length;
IPos limit;
* 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 = (uInt)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
/*
* Stop when cur_match becomes <= limit. To simplify the code,
local unsigned std2_longest_match(deflate_state *z_const s, IPos cur_match)
{
z_const unsigned wmask = s->w_mask;
- z_const Posf *prev = s->prev;
+ z_const Pos *prev = s->prev;
unsigned short scan_start, scan_end;
unsigned chain_length;
* 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 = (uInt)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
/*
* Stop when cur_match becomes <= limit. To simplify the code,
struct static_tree_desc_s {
const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code 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 */
local void init_block (deflate_state *s);
local void pqdownheap (deflate_state *s, ct_data *tree, int k);
local void gen_bitlen (deflate_state *s, tree_desc *desc);
-local void gen_codes (ct_data *tree, int max_code, ushf *bl_count);
+local void gen_codes (ct_data *tree, int max_code, ush *bl_count);
local void build_tree (deflate_state *s, tree_desc *desc);
local void scan_tree (deflate_state *s, ct_data *tree, int max_code);
local void send_tree (deflate_state *s, ct_data *tree, int max_code);
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, charf *buf, unsigned len, int header);
+local void copy_block (deflate_state *s, char *buf, unsigned len, int header);
#ifdef GEN_TREES_H
local void gen_trees_header (void);
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
+ const int *extra = desc->stat_desc->extra_bits;
int base = desc->stat_desc->extra_base;
int max_length = desc->stat_desc->max_length;
int h; /* heap index */
local void gen_codes (tree, max_code, bl_count)
ct_data *tree; /* the tree to decorate */
int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
+ ush *bl_count; /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
ush code = 0; /* running code value */
*/
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
deflate_state *s;
- charf *buf; /* input block */
+ char *buf; /* input block */
ulg stored_len; /* length of input block */
int last; /* one if this is the last block for a file */
{
*/
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
+ char *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */
int last; /* one if this is the last block for a file */
{
*/
local void copy_block(s, buf, len, header)
deflate_state *s;
- charf *buf; /* the input data */
+ char *buf; /* the input data */
unsigned len; /* its length */
int header; /* true if block header must be written */
{
buffer, or Z_DATA_ERROR if the input data was corrupted.
*/
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
+ Byte *dest;
+ uLong *destLen;
+ const Byte *source;
uLong sourceLen;
{
z_stream stream;
int err;
- stream.next_in = (z_const Bytef *)source;
+ stream.next_in = (z_const Byte *)source;
stream.avail_in = (uInt)sourceLen;
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
struct internal_state;
typedef struct z_stream_s {
- z_const Bytef *next_in; /* next input byte */
+ z_const Byte *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 */
- Bytef *next_out; /* next output byte should be put there */
+ Byte *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 */
uLong time; /* modification time */
int xflags; /* extra flags (not used when writing a gzip file) */
int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
+ Byte *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) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
+ Byte *name; /* pointer to zero-terminated file name or Z_NULL */
uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
+ Byte *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
*/
ZEXTERN int ZEXPORT deflateSetDictionary (z_streamp strm,
- const Bytef *dictionary,
+ const Byte *dictionary,
uInt dictLength);
/*
Initializes the compression dictionary from the given byte sequence
*/
ZEXTERN int ZEXPORT inflateSetDictionary (z_streamp strm,
- const Bytef *dictionary,
+ const Byte *dictionary,
uInt dictLength);
/*
Initializes the decompression dictionary from the given uncompressed byte
*/
ZEXTERN int ZEXPORT inflateGetDictionary (z_streamp strm,
- Bytef *dictionary,
+ Byte *dictionary,
uInt *dictLength);
/*
Returns the sliding dictionary being maintained by inflate. dictLength is
you need special options.
*/
-ZEXTERN int ZEXPORT compress (Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen);
+ZEXTERN int ZEXPORT compress (Byte *dest, uLong *destLen,
+ const Byte *source, uLong 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 (Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
+ZEXTERN int ZEXPORT compress2 (Byte *dest, uLong *destLen,
+ const Byte *source, uLong sourceLen,
int level);
/*
Compresses the source buffer into the destination buffer. The level
compress() or compress2() call to allocate the destination buffer.
*/
-ZEXTERN int ZEXPORT uncompress (Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen);
+ZEXTERN int ZEXPORT uncompress (Byte *dest, uLong *destLen,
+ const Byte *source, uLong 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 uLong ZEXPORT adler32 (uLong adler, const Bytef *buf, uInt len);
+ZEXTERN uLong ZEXPORT adler32 (uLong adler, const Byte *buf, uInt 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 uLong ZEXPORT crc32 (uLong crc, const Bytef *buf, uInt len);
+ZEXTERN uLong ZEXPORT crc32 (uLong crc, const Byte *buf, uInt 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
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
-typedef uch uchf;
typedef unsigned short ush;
-typedef ush ushf;
typedef unsigned long ulg;
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */