Only internal functions, no exported functions in this commit.
}
/* ========================================================================= */
-local uLong adler32_combine_(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off64_t len2;
+local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
{
unsigned long sum1;
unsigned long sum2;
}
#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const z_crc_t *table;
+local void write_table(FILE *out, const z_crc_t *table)
{
int n;
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char *buf;
- unsigned len;
+local unsigned long crc32_little(unsigned long crc, const unsigned char *buf, unsigned len)
{
register z_crc_t c;
register const z_crc_t *buf4;
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char *buf;
- unsigned len;
+local unsigned long crc32_big(unsigned long crc, const unsigned char *buf, unsigned len)
{
register z_crc_t c;
register const z_crc_t *buf4;
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
+local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
{
unsigned long sum;
}
/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
+local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
{
int n;
}
/* ========================================================================= */
-local uLong crc32_combine_(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off64_t len2;
+local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
{
int n;
unsigned long row;
* IN assertion: the stream state is correct and there is enough room in
* pending_buf.
*/
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
+local void putShortMSB (deflate_state *s, uInt b)
{
put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff));
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
-ZLIB_INTERNAL int read_buf(strm, buf, size)
- z_streamp strm;
- Byte *buf;
- unsigned size;
+ZLIB_INTERNAL int read_buf(z_streamp strm, Byte *buf, unsigned size)
{
unsigned len = strm->avail_in;
/* ===========================================================================
* Initialize the "longest match" routines for a new zlib stream
*/
-local void lm_init (s)
- deflate_state *s;
+local void lm_init (deflate_state *s)
{
s->window_size = (ulg)2L*s->w_size;
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
+local void check_match(deflate_state *s, IPos start, IPos match, int length)
{
/* check that the match is indeed a match */
if (zmemcmp(s->window + match,
fill_window_c(s);
}
-local void fill_window_c(s)
- deflate_state *s;
+local void fill_window_c(deflate_state *s)
{
register unsigned n;
register Pos *p;
* NOTE: this function should be optimized to avoid extra copying from
* window to pending_buf.
*/
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
+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:
* new strings in the dictionary only for unmatched strings or for short
* matches. It is used only for the fast compression options.
*/
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_fast(deflate_state *s, int flush)
{
IPos hash_head; /* head of the hash chain */
int bflush; /* set if current block must be flushed */
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_slow(deflate_state *s, int flush)
{
IPos hash_head; /* head of hash chain */
int bflush; /* set if current block must be flushed */
* one. Do not maintain a hash table. (It will be regenerated if this run of
* deflate switches away from Z_RLE.)
*/
-local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_rle(deflate_state *s, int flush)
{
int bflush; /* set if current block must be flushed */
uInt prev; /* byte at distance one to match */
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
* (It will be regenerated if this run of deflate switches away from Huffman.)
*/
-local block_state deflate_huff(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_huff(deflate_state *s, int flush)
{
int bflush; /* set if current block must be flushed */
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
+local void send_bits(deflate_state *s,
+ int value, /* value to send */
+ int length /* number of bits */
{
Tracevv((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
The gz_strwinerror function does not change the current setting of
GetLastError. */
-char ZLIB_INTERNAL *gz_strwinerror (error)
- DWORD error;
+char ZLIB_INTERNAL *gz_strwinerror (DWORD error)
{
static char buf[1024];
#endif /* UNDER_CE */
/* Reset gzip file state */
-local void gz_reset(state)
- gz_statep state;
+local void gz_reset(gz_statep state)
{
state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */
}
/* Open a gzip file either by name or file descriptor. */
-local gzFile gz_open(path, fd, mode)
- const void *path;
- int fd;
- const char *mode;
+local gzFile gz_open(const void *path, int fd, const char *mode)
{
gz_statep state;
size_t len;
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
-void ZLIB_INTERNAL gz_error(state, err, msg)
- gz_statep state;
- int err;
- const char *msg;
+void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
{
/* free previously allocated message and clear */
if (state->msg != NULL) {
state->fd, and update state->eof, state->err, and state->msg as appropriate.
This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. */
-local int gz_load(state, buf, len, have)
- gz_statep state;
- unsigned char *buf;
- unsigned len;
- unsigned *have;
+local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
{
int ret;
If strm->avail_in != 0, then the current data is moved to the beginning of
the input buffer, and then the remainder of the buffer is loaded with the
available data from the input file. */
-local int gz_avail(state)
- gz_statep state;
+local int gz_avail(gz_statep state)
{
unsigned got;
z_streamp strm = &(state->strm);
case, all further file reads will be directly to either the output buffer or
a user buffer. If decompressing, the inflate state will be initialized.
gz_look() will return 0 on success or -1 on failure. */
-local int gz_look(state)
- gz_statep state;
+local int gz_look(gz_statep state)
{
z_streamp strm = &(state->strm);
data. If the gzip stream completes, state->how is reset to LOOK to look for
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
on success, -1 on failure. */
-local int gz_decomp(state)
- gz_statep state;
+local int gz_decomp(gz_statep state)
{
int ret = Z_OK;
unsigned had;
looked for to determine whether to copy or decompress. Returns -1 on error,
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
end of the input file has been reached and all data has been processed. */
-local int gz_fetch(state)
- gz_statep state;
+local int gz_fetch(gz_statep state)
{
z_streamp strm = &(state->strm);
}
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
-local int gz_skip(state, len)
- gz_statep state;
- z_off64_t len;
+local int gz_skip(gz_statep state, z_off64_t len)
{
unsigned n;
/* Initialize state for writing a gzip file. Mark initialization by setting
state->size to non-zero. Return -1 on failure or 0 on success. */
-local int gz_init(state)
- gz_statep state;
+local int gz_init(gz_statep state)
{
int ret;
z_streamp strm = &(state->strm);
then the deflate() state is reset to start a new gzip stream. If gz->direct
is true, then simply write to the output file without compressing, and
ignore flush. */
-local int gz_comp(state, flush)
- gz_statep state;
- int flush;
+local int gz_comp(gz_statep state, int flush)
{
int ret, got;
unsigned have;
}
/* Compress len zeros to output. Return -1 on error, 0 on success. */
-local int gz_zero(state, len)
- gz_statep state;
- z_off64_t len;
+local int gz_zero(gz_statep state, z_off64_t len)
{
int first;
unsigned n;
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
-local void fixedtables(state)
-struct inflate_state *state;
+local void fixedtables(struct inflate_state *state)
{
#ifdef BUILDFIXED
static int virgin = 1;
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
-void ZLIB_INTERNAL inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
+void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
{
+ /* start: inflate()'s starting value for strm->avail_out */
struct inflate_state *state;
z_const unsigned char *in; /* local strm->next_in */
z_const unsigned char *last; /* have enough input while in < last */
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
-local void fixedtables(state)
-struct inflate_state *state;
+local void fixedtables(struct inflate_state *state)
{
#ifdef BUILDFIXED
static int virgin = 1;
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
-local int updatewindow(strm, end, copy)
-z_streamp strm;
-const Byte *end;
-unsigned copy;
+local int updatewindow(z_streamp strm, const Byte *end, unsigned copy)
{
struct inflate_state *state;
unsigned dist;
called again with more data and the *have state. *have is initialized to
zero for the first call.
*/
-local unsigned syncsearch(have, buf, len)
-unsigned *have;
-const unsigned char *buf;
-unsigned len;
+local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len)
{
unsigned got;
unsigned next;
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(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short *lens;
-unsigned codes;
-code * *table;
-unsigned *bits;
-unsigned short *work;
+int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned codes,
+ code * *table, unsigned *bits, unsigned short *work)
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
uLong dictId; /* Adler32 value of the dictionary */
void test_deflate (Byte *compr, uLong comprLen);
-void test_inflate (Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen);
-void test_large_deflate (Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen);
-void test_large_inflate (Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen);
+void test_inflate (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen);
+void test_large_deflate (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen);
+void test_large_inflate (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen);
void test_flush (Byte *compr, uLong *comprLen);
-void test_sync (Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen);
+void test_sync (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen);
void test_dict_deflate (Byte *compr, uLong comprLen);
-void test_dict_inflate (Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen);
+void test_dict_inflate (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen);
int main (int argc, char *argv[]);
void *myalloc (void *, unsigned, unsigned);
void myfree (void *, void *);
-void *myalloc(q, n, m)
- void *q;
- unsigned n, m;
+void *myalloc(void *q, unsigned n, unsigned m)
{
q = Z_NULL;
return calloc(n, m);
/* ===========================================================================
* Test compress() and uncompress()
*/
-void test_compress(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
uLong len = (uLong)strlen(hello)+1;
/* ===========================================================================
* Test read/write of .gz files
*/
-void test_gzio(fname, uncompr, uncomprLen)
- const char *fname; /* compressed file name */
- Byte *uncompr;
- uLong uncomprLen;
+void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen)
{
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
/* ===========================================================================
* Test deflate() with small buffers
*/
-void test_deflate(compr, comprLen)
- Byte *compr;
- uLong comprLen;
+void test_deflate(Byte *compr, uLong comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with small buffers
*/
-void test_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
-void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with large buffers
*/
-void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with full flush
*/
-void test_flush(compr, comprLen)
- Byte *compr;
- uLong *comprLen;
+void test_flush(Byte *compr, uLong *comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflateSync()
*/
-void test_sync(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with preset dictionary
*/
-void test_dict_deflate(compr, comprLen)
- Byte *compr;
- uLong comprLen;
+void test_dict_deflate(Byte *compr, uLong comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
-void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
+void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
* Usage: example [output.gz [input.gz]]
*/
-int main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
Byte *compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
header information is collected with inflateGetHeader(). If a zlib stream
is looking for a dictionary, then an empty dictionary is provided.
inflate() is run until all of the input data is consumed. */
-local void inf(char *hex, char *what, unsigned step, int win, unsigned len,
- int err)
+local void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err)
{
int ret;
unsigned have;
The strwinerror function does not change the current setting
of GetLastError. */
-static char *strwinerror (error)
- DWORD error;
+static char *strwinerror (DWORD error)
{
static char buf[1024];
return buf;
}
-static void pwinerror (s)
- const char *s;
+static void pwinerror (const char *s)
{
if (s && *s)
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
void *myalloc (void *, unsigned, unsigned);
void myfree (void *, void *);
-void *myalloc(q, n, m)
- void *q;
- unsigned n, m;
+void *myalloc(void *q, unsigned n, unsigned m)
{
q = Z_NULL;
return calloc(n, m);
}
-void myfree(q, p)
- void *q, *p;
+void myfree(void *q, void *p)
{
q = Z_NULL;
free(p);
gzFile gzdopen (int, const char *);
gzFile gz_open (const char *, int, const char *);
-gzFile gzopen(path, mode)
-const char *path;
-const char *mode;
+gzFile gzopen(const char *path, const char *mode)
{
return gz_open(path, -1, mode);
}
-gzFile gzdopen(fd, mode)
-int fd;
-const char *mode;
+gzFile gzdopen(int fd, const char *mode)
{
return gz_open(NULL, fd, mode);
}
-gzFile gz_open(path, fd, mode)
- const char *path;
- int fd;
- const char *mode;
+gzFile gz_open(const char *path, int fd, const char *mode)
{
gzFile gz;
int ret;
int gzwrite (gzFile, const void *, unsigned);
-int gzwrite(gz, buf, len)
- gzFile gz;
- const void *buf;
- unsigned len;
+int gzwrite(gzFile gz, const void *buf, unsigned len)
{
z_stream *strm;
unsigned char out[BUFLEN];
int gzread (gzFile, void *, unsigned);
-int gzread(gz, buf, len)
- gzFile gz;
- void *buf;
- unsigned len;
+int gzread(gzFile gz, void *buf, unsigned len)
{
int ret;
unsigned got;
int gzclose (gzFile);
-int gzclose(gz)
- gzFile gz;
+int gzclose(gzFile gz)
{
z_stream *strm;
unsigned char out[BUFLEN];
const char *gzerror (gzFile, int *);
-const char *gzerror(gz, err)
- gzFile gz;
- int *err;
+const char *gzerror(gzFile gz, int *err)
{
*err = gz->err;
return gz->msg;
/* ===========================================================================
* Display error message and exit
*/
-void error(msg)
- const char *msg;
+void error(const char *msg)
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
* Compress input to output then close both files.
*/
-void gz_compress(in, out)
- FILE *in;
- gzFile out;
+void gz_compress(FILE *in, gzFile out)
{
local char buf[BUFLEN];
int len;
/* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise.
*/
-int gz_compress_mmap(in, out)
- FILE *in;
- gzFile out;
+int gz_compress_mmap(FILE *in, gzFile out)
{
int len;
int err;
/* ===========================================================================
* Uncompress input to output then close both files.
*/
-void gz_uncompress(in, out)
- gzFile in;
- FILE *out;
+void gz_uncompress(gzFile in, FILE *out)
{
local char buf[BUFLEN];
int len;
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
-void file_compress(file, mode)
- char *file;
- char *mode;
+void file_compress(char *file, char *mode)
{
local char outfile[MAX_NAME_LEN];
FILE *in;
/* ===========================================================================
* Uncompress the given file and remove the original.
*/
-void file_uncompress(file)
- char *file;
+void file_uncompress(char *file)
{
local char buf[MAX_NAME_LEN];
char *infile, *outfile;
* -1 to -9 : compression level
*/
-int main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
int copyout = 0;
int uncompr = 0;
/* ===========================================================================
* Initialize the tree data structures for a new zlib stream.
*/
-void ZLIB_INTERNAL _tr_init(s)
- deflate_state *s;
+void ZLIB_INTERNAL _tr_init(deflate_state *s)
{
tr_static_init();
/* ===========================================================================
* Initialize a new block.
*/
-local void init_block(s)
- deflate_state *s;
+local void init_block(deflate_state *s)
{
int n; /* iterates over tree elements */
* when the heap property is re-established (each father smaller than its
* two sons).
*/
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
+local void pqdownheap(deflate_state *s, ct_data *tree, int k)
{
+ /* tree: the tree to restore */
+ /* k: node to move down */
int v = s->heap[k];
int j = k << 1; /* left son of k */
while (j <= s->heap_len) {
* The length opt_len is updated; static_len is also updated if stree is
* not null.
*/
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+local void gen_bitlen(deflate_state *s, tree_desc *desc)
{
+ /* desc: the tree descriptor */
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
const ct_data *stree = desc->stat_desc->static_tree;
* OUT assertion: the field code is set for all tree elements of non
* zero code length.
*/
-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 */
- ush *bl_count; /* number of codes at each bit length */
+local void gen_codes (ct_data *tree, int max_code, ush *bl_count)
{
+ /* tree: the tree to decorate */
+ /* max_code: largest code with non zero frequency */
+ /* 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 */
int bits; /* bit index */
* and corresponding code. The length opt_len is updated; static_len is
* also updated if stree is not null. The field max_code is set.
*/
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+local void build_tree(deflate_state *s, tree_desc *desc)
{
+ /* desc: the tree descriptor */
ct_data *tree = desc->dyn_tree;
const ct_data *stree = desc->stat_desc->static_tree;
int elems = desc->stat_desc->elems;
* Scan a literal or distance tree to determine the frequencies of the codes
* in the bit length tree.
*/
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
{
+ /* tree: the tree to be scanned */
+ /* max_code: and its largest code of non zero frequency */
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
int curlen; /* length of current code */
* Send a literal or distance tree in compressed form, using the codes in
* bl_tree.
*/
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+local void send_tree (deflate_state *s, ct_data *tree, int max_code)
{
+ /* tree: the tree to be scanned */
+ /* max_code and its largest code of non zero frequency */
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
int curlen; /* length of current code */
* Construct the Huffman tree for the bit lengths and return the index in
* bl_order of the last bit length code to send.
*/
-local int build_bl_tree(s)
- deflate_state *s;
+local int build_bl_tree(deflate_state *s)
{
int max_blindex; /* index of last bit length code of non zero freq */
* lengths of the bit length codes, the literal tree and the distance tree.
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
*/
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
+local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
{
int rank; /* index in bl_order */
/* ===========================================================================
* Send a stored block
*/
-void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
- 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 */
+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 */
{
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
#ifdef DEBUG
/* ===========================================================================
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
*/
-void ZLIB_INTERNAL _tr_flush_bits(s)
- deflate_state *s;
+void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
{
bi_flush(s);
}
* Send one empty static block to give enough lookahead for inflate.
* This takes 10 bits, of which 7 may remain in the bit buffer.
*/
-void ZLIB_INTERNAL _tr_align(s)
- deflate_state *s;
+void ZLIB_INTERNAL _tr_align(deflate_state *s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
* 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(s, buf, stored_len, last)
- deflate_state *s;
- 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 */
+void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, ulg 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 */
int max_blindex = 0; /* index of last bit length code of non zero freq */
* Save the match info and tally the frequency counts. Return true if
* the current block must be flushed.
*/
-int ZLIB_INTERNAL _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
+int ZLIB_INTERNAL _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
{
+ /* dist: distance of matched string */
+ /* lc: match length-MIN_MATCH or unmatched char (if dist==0) */
s->d_buf[s->last_lit] = (ush)dist;
s->l_buf[s->last_lit++] = (uch)lc;
if (dist == 0) {
/* ===========================================================================
* Send the block data compressed using the given Huffman trees
*/
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- const ct_data *ltree; /* literal tree */
- const ct_data *dtree; /* distance tree */
+local void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree)
{
+ /* ltree: literal tree */
+ /* dtree: distance tree */
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
unsigned lx = 0; /* running index in l_buf */
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
* IN assertion: the fields Freq of dyn_ltree are set.
*/
-local int detect_data_type(s)
- deflate_state *s;
+local int detect_data_type(deflate_state *s)
{
/* black_mask is the bit mask of black-listed bytes
* set bits 0..6, 14..25, and 28..31
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
+local unsigned bi_reverse(unsigned code, int len)
{
+ /* code: the value to invert */
+ /* len: its bit length */
register unsigned res = 0;
do {
res |= code & 1;
/* ===========================================================================
* Flush the bit buffer, keeping at most 7 bits in it.
*/
-local void bi_flush(s)
- deflate_state *s;
+local void bi_flush(deflate_state *s)
{
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
-ZLIB_INTERNAL void bi_windup(s)
- deflate_state *s;
+ZLIB_INTERNAL void bi_windup(deflate_state *s)
{
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
* Copy a stored block, storing first the length and its
* one's complement if requested.
*/
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- char *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
+local void copy_block(deflate_state *s, char *buf, unsigned len, int header)
{
+ /* buf: the input data */
+ /* len: its length */
+ /* header: true if block header must be written */
bi_windup(s); /* align on byte boundary */
if (header) {
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-voidp ZLIB_INTERNAL zcalloc (opaque, items, size)
- voidp opaque;
- unsigned items;
- unsigned size;
+voidp ZLIB_INTERNAL zcalloc (voidp opaque, unsigned items, unsigned size)
{
if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidp)malloc(items * size) :
(voidp)calloc(items, size);
}
-void ZLIB_INTERNAL zcfree (opaque, ptr)
- voidp opaque;
- voidp ptr;
+void ZLIB_INTERNAL zcfree (voidp opaque, voidp ptr)
{
free(ptr);
if (opaque) return; /* make compiler happy */