From: Daniel Axtens Date: Fri, 8 May 2015 11:46:51 +0000 (+1000) Subject: Kill Byte and Bytef X-Git-Tag: 1.9.9-b1~819 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24cfc4d7bbd36bea89547a5538715956a2996dad;p=thirdparty%2Fzlib-ng.git Kill Byte and Bytef Signed-off-by: Daniel Axtens Conflicts: adler32.c compress.c deflate.c inflate.c match.c test/example.c uncompr.c zlib.h --- diff --git a/adler32.c b/adler32.c index bbd03efac..7cded1d25 100644 --- a/adler32.c +++ b/adler32.c @@ -60,7 +60,7 @@ static uint32_t adler32_combine_ (uint32_t adler1, uint32_t adler2, z_off64_t le #endif /* ========================================================================= */ -uint32_t ZEXPORT adler32(uint32_t adler, const Byte *buf, uInt len) +uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len) { uint32_t sum2; unsigned n; diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index 89a33cf8b..70c6ca9cc 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -13,7 +13,7 @@ #include #include "deflate.h" -extern int read_buf (z_stream *strm, Byte *buf, unsigned size); +extern int read_buf (z_stream *strm, unsigned char *buf, unsigned size); ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { diff --git a/compress.c b/compress.c index d2e8459cb..9af08d045 100644 --- a/compress.c +++ b/compress.c @@ -19,13 +19,13 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2 (Byte *dest, uLong *destLen, const Byte *source, +int ZEXPORT compress2 (unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen, int level) { z_stream stream; int err; - stream.next_in = (const Byte *)source; + stream.next_in = (const unsigned char *)source; stream.avail_in = (uInt)sourceLen; stream.next_out = dest; stream.avail_out = (uInt)*destLen; @@ -51,7 +51,7 @@ int ZEXPORT compress2 (Byte *dest, uLong *destLen, const Byte *source, /* =========================================================================== */ -int ZEXPORT compress (Byte *dest, uLong *destLen, const Byte *source, uLong sourceLen) +int ZEXPORT compress (unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } diff --git a/crc32.c b/crc32.c index e4fe6c57e..66d685880 100644 --- a/crc32.c +++ b/crc32.c @@ -441,7 +441,7 @@ ZLIB_INTERNAL void crc_finalize(deflate_state *const s) #endif } -ZLIB_INTERNAL void copy_with_crc(z_stream *strm, Byte *dst, long size) +ZLIB_INTERNAL void copy_with_crc(z_stream *strm, unsigned char *dst, long size) { #ifdef X86_PCLMULQDQ_CRC if (x86_cpu_has_pclmulqdq) { diff --git a/deflate.c b/deflate.c index fe4995f65..9861a7fa8 100644 --- a/deflate.c +++ b/deflate.c @@ -85,7 +85,7 @@ local block_state deflate_huff (deflate_state *s, int flush); local void lm_init (deflate_state *s); local void putShortMSB (deflate_state *s, uInt b); ZLIB_INTERNAL void flush_pending (z_stream *strm); -ZLIB_INTERNAL int read_buf (z_stream *strm, Byte *buf, unsigned size); +ZLIB_INTERNAL int read_buf (z_stream *strm, unsigned char *buf, unsigned size); #ifdef DEBUG local void check_match (deflate_state *s, IPos start, IPos match, int length); @@ -93,7 +93,7 @@ local void check_match (deflate_state *s, IPos start, IPos match, int length); extern void crc_reset(deflate_state *const s); extern void crc_finalize(deflate_state *const s); -extern void copy_with_crc(z_stream *strm, Byte *dst, long size); +extern void copy_with_crc(z_stream *strm, unsigned char *dst, long size); /* =========================================================================== * Local data @@ -230,7 +230,7 @@ bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) { */ #define CLEAR_HASH(s) \ s->head[s->hash_size-1] = NIL; \ - memset((Byte *)s->head, 0, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + memset((unsigned char *)s->head, 0, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ int ZEXPORT deflateInit_(z_stream *strm, int level, const char *version, int stream_size) @@ -322,7 +322,7 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, window_padding = 8; #endif - s->window = (Byte *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(Byte)); + s->window = (unsigned char *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(unsigned char)); s->prev = (Pos *) ZALLOC(strm, s->w_size, sizeof(Pos)); s->head = (Pos *) ZALLOC(strm, s->hash_size, sizeof(Pos)); @@ -346,13 +346,13 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, s->level = level; s->strategy = strategy; - s->method = (Byte)method; + s->method = (unsigned char)method; return deflateReset(strm); } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary (z_stream *strm, const Byte *dictionary, uInt dictLength) +int ZEXPORT deflateSetDictionary (z_stream *strm, const unsigned char *dictionary, uInt dictLength) { deflate_state *s; uInt str, n; @@ -388,7 +388,7 @@ int ZEXPORT deflateSetDictionary (z_stream *strm, const Byte *dictionary, uInt avail = strm->avail_in; next = strm->next_in; strm->avail_in = dictLength; - strm->next_in = (const Byte *)dictionary; + strm->next_in = (const unsigned char *)dictionary; fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; @@ -488,7 +488,7 @@ int ZEXPORT deflatePrime (z_stream *strm, int bits, int value) if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; s = strm->state; - if ((Byte *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) + if ((unsigned char *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; do { put = Buf_size - s->bi_valid; @@ -573,7 +573,7 @@ uLong ZEXPORT deflateBound(z_stream *strm, uLong sourceLen) { deflate_state *s; uLong complen, wraplen; - Byte *str; + unsigned char *str; /* conservative upper bound for compressed data */ complen = sourceLen + @@ -631,8 +631,8 @@ uLong ZEXPORT deflateBound(z_stream *strm, uLong sourceLen) */ local void putShortMSB (deflate_state *s, uInt b) { - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); + put_byte(s, (unsigned char)(b >> 8)); + put_byte(s, (unsigned char)(b & 0xff)); } /* ========================================================================= @@ -713,10 +713,10 @@ int ZEXPORT deflate (z_stream *strm, int flush) (s->gzhead->name == Z_NULL ? 0 : 8) + (s->gzhead->comment == Z_NULL ? 0 : 16) ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, (unsigned char)(s->gzhead->time & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 24) & 0xff)); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); @@ -855,8 +855,8 @@ int ZEXPORT deflate (z_stream *strm, int flush) if (s->pending + 2 > s->pending_buf_size) flush_pending(strm); if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (unsigned char)(strm->adler & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 8) & 0xff)); strm->adler = crc32(0L, Z_NULL, 0); s->status = BUSY_STATE; } @@ -960,14 +960,14 @@ int ZEXPORT deflate (z_stream *strm, int flush) #ifdef GZIP if (s->wrap == 2) { crc_finalize(s); - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + put_byte(s, (unsigned char)(strm->adler & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 8) & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 16) & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 24) & 0xff)); + put_byte(s, (unsigned char)(strm->total_in & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 8) & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 16) & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 24) & 0xff)); } else #endif @@ -1037,7 +1037,7 @@ int ZEXPORT deflateCopy (z_stream *dest, z_stream *source) memcpy((void *)ds, (void *)ss, sizeof(deflate_state)); ds->strm = dest; - ds->window = (Byte *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->window = (unsigned char *) ZALLOC(dest, ds->w_size, 2*sizeof(unsigned char)); 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); @@ -1049,7 +1049,7 @@ int ZEXPORT deflateCopy (z_stream *dest, z_stream *source) return Z_MEM_ERROR; } - memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(unsigned char)); memcpy((void *)ds->prev, (void *)ss->prev, ds->w_size * sizeof(Pos)); memcpy((void *)ds->head, (void *)ss->head, ds->hash_size * sizeof(Pos)); memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); @@ -1072,7 +1072,7 @@ int ZEXPORT deflateCopy (z_stream *dest, z_stream *source) * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -ZLIB_INTERNAL int read_buf(z_stream *strm, Byte *buf, unsigned size) +ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size) { unsigned len = strm->avail_in; @@ -1681,7 +1681,7 @@ 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 */ - Byte *scan, *strend; /* scan goes up to strend for length of run */ + unsigned char *scan, *strend; /* scan goes up to strend for length of run */ for (;;) { /* Make sure that we always have enough lookahead, except diff --git a/deflate.h b/deflate.h index a76a94dfa..ef974c373 100644 --- a/deflate.h +++ b/deflate.h @@ -103,14 +103,14 @@ typedef unsigned IPos; typedef struct internal_state { z_stream *strm; /* pointer back to this zlib stream */ int status; /* as the name implies */ - Byte *pending_buf; /* output still pending */ + unsigned char *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ - Byte *pending_out; /* next pending byte to output to the stream */ + unsigned char *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 gzindex; /* where in extra, name, or comment */ - Byte method; /* can only be DEFLATED */ + unsigned char method; /* can only be DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ #ifdef X86_PCLMULQDQ_CRC @@ -123,7 +123,7 @@ typedef struct internal_state { uInt w_bits; /* log2(w_size) (8..16) */ uInt w_mask; /* w_size - 1 */ - Byte *window; + unsigned char *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 diff --git a/gzwrite.c b/gzwrite.c index 5e4b3a14c..90811fb0c 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -223,7 +223,7 @@ int ZEXPORT gzwrite(gzFile file, void const *buf, unsigned len) /* directly compress user buffer to file */ strm->avail_in = len; - strm->next_in = (const Byte *)buf; + strm->next_in = (const unsigned char *)buf; state->x.pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; diff --git a/inflate.c b/inflate.c index cf3959dc2..a3a342f97 100644 --- a/inflate.c +++ b/inflate.c @@ -352,7 +352,7 @@ void makefixed() 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(z_stream *strm, const Byte *end, unsigned copy) +local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) { struct inflate_state *state; unsigned dist; @@ -1235,7 +1235,7 @@ int ZEXPORT inflateEnd(z_stream *strm) return Z_OK; } -int ZEXPORT inflateGetDictionary(z_stream *strm, Byte *dictionary, uInt *dictLength) +int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt *dictLength) { struct inflate_state *state; @@ -1255,7 +1255,7 @@ int ZEXPORT inflateGetDictionary(z_stream *strm, Byte *dictionary, uInt *dictLen return Z_OK; } -int ZEXPORT inflateSetDictionary(z_stream *strm, const Byte *dictionary, uInt dictLength) +int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) { struct inflate_state *state; unsigned long dictid; diff --git a/match.c b/match.c index d76a5d0a8..7a58b2763 100644 --- a/match.c +++ b/match.c @@ -337,8 +337,8 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Byte *scan = s->window + s->strstart; /* current string */ - register Byte *match; /* matched string */ + register unsigned char *scan = s->window + s->strstart; /* current string */ + register unsigned char *match; /* matched string */ register unsigned int len; /* length of current match */ unsigned int best_len = s->prev_length; /* best match length so far */ unsigned int nice_match = s->nice_match; /* stop if match long enough */ @@ -350,7 +350,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) Pos *prev = s->prev; uInt wmask = s->w_mask; - register Byte *strend = s->window + s->strstart + MAX_MATCH; + 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); @@ -381,7 +381,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) * However the length of the match is limited to the lookahead, so * the output of deflate is not affected by the uninitialized values. */ - Byte *win = s->window; + unsigned char *win = s->window; int cont = 1; do { match = win + cur_match; diff --git a/test/example.c b/test/example.c index a448b7e24..a9b730ea5 100644 --- a/test/example.c +++ b/test/example.c @@ -28,32 +28,32 @@ const char hello[] = "hello, hello!"; const char dictionary[] = "hello"; 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_flush (Byte *compr, uLong *comprLen); -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_deflate (unsigned char *compr, uLong comprLen); +void test_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen); +void test_large_deflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen); +void test_large_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen); +void test_flush (unsigned char *compr, uLong *comprLen); +void test_sync (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen); +void test_dict_deflate (unsigned char *compr, uLong comprLen); +void test_dict_inflate (unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen); int main (int argc, char *argv[]); static alloc_func zalloc = (alloc_func)0; static free_func zfree = (free_func)0; -void test_compress (Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen); +void test_compress (unsigned char *compr, uLong comprLen, + unsigned char *uncompr, uLong uncomprLen); /* =========================================================================== * Test compress() and uncompress() */ -void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_compress(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { int err; uLong len = (uLong)strlen(hello)+1; - err = compress(compr, &comprLen, (const Byte*)hello, len); + err = compress(compr, &comprLen, (const unsigned char*)hello, len); CHECK_ERR(err, "compress"); strcpy((char*)uncompr, "garbage"); @@ -76,7 +76,7 @@ void test_gzio (const char *fname, /* =========================================================================== * Test read/write of .gz files */ -void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) +void test_gzio(const char *fname, unsigned char *uncompr, uLong uncomprLen) { #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); @@ -159,7 +159,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) /* =========================================================================== * Test deflate() with small buffers */ -void test_deflate(Byte *compr, uLong comprLen) +void test_deflate(unsigned char *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; @@ -195,7 +195,7 @@ void test_deflate(Byte *compr, uLong comprLen) /* =========================================================================== * Test inflate() with small buffers */ -void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -234,7 +234,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ -void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_large_deflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { z_stream c_stream; /* compression stream */ int err; @@ -287,7 +287,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomp /* =========================================================================== * Test inflate() with large buffers */ -void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_large_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -326,7 +326,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomp /* =========================================================================== * Test deflate() with full flush */ -void test_flush(Byte *compr, uLong *comprLen) +void test_flush(unsigned char *compr, uLong *comprLen) { z_stream c_stream; /* compression stream */ int err; @@ -362,7 +362,7 @@ void test_flush(Byte *compr, uLong *comprLen) /* =========================================================================== * Test inflateSync() */ -void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_sync(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -404,7 +404,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) /* =========================================================================== * Test deflate() with preset dictionary */ -void test_dict_deflate(Byte *compr, uLong comprLen) +void test_dict_deflate(unsigned char *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; @@ -417,7 +417,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) CHECK_ERR(err, "deflateInit"); err = deflateSetDictionary(&c_stream, - (const Byte*)dictionary, (int)sizeof(dictionary)); + (const unsigned char*)dictionary, (int)sizeof(dictionary)); CHECK_ERR(err, "deflateSetDictionary"); dictId = c_stream.adler; @@ -439,7 +439,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) /* =========================================================================== * Test inflate() with a preset dictionary */ -void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) +void test_dict_inflate(unsigned char *compr, uLong comprLen, unsigned char *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -467,7 +467,7 @@ void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncompr fprintf(stderr, "unexpected dictionary"); exit(1); } - err = inflateSetDictionary(&d_stream, (const Byte*)dictionary, + err = inflateSetDictionary(&d_stream, (const unsigned char*)dictionary, (int)sizeof(dictionary)); } CHECK_ERR(err, "inflate with dict"); @@ -490,7 +490,7 @@ void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncompr int main(int argc, char *argv[]) { - Byte *compr, *uncompr; + unsigned char *compr, *uncompr; uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char* myVersion = ZLIB_VERSION; @@ -506,8 +506,8 @@ int main(int argc, char *argv[]) printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); - compr = (Byte*)calloc((uInt)comprLen, 1); - uncompr = (Byte*)calloc((uInt)uncomprLen, 1); + compr = (unsigned char*)calloc((uInt)comprLen, 1); + uncompr = (unsigned char*)calloc((uInt)uncomprLen, 1); /* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. */ diff --git a/trees.c b/trees.c index c735f008a..a02bab7d1 100644 --- a/trees.c +++ b/trees.c @@ -1080,7 +1080,7 @@ local void bi_flush(deflate_state *s) s->bi_buf = 0; s->bi_valid = 0; } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); + put_byte(s, (unsigned char)s->bi_buf); s->bi_buf >>= 8; s->bi_valid -= 8; } @@ -1094,7 +1094,7 @@ ZLIB_INTERNAL void bi_windup(deflate_state *s) if (s->bi_valid > 8) { put_short(s, s->bi_buf); } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); + put_byte(s, (unsigned char)s->bi_buf); } s->bi_buf = 0; s->bi_valid = 0; diff --git a/uncompr.c b/uncompr.c index 59d44b22b..556b8678d 100644 --- a/uncompr.c +++ b/uncompr.c @@ -21,12 +21,12 @@ enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. */ -int ZEXPORT uncompress (Byte *dest, uLong *destLen, const Byte *source, uLong sourceLen) +int ZEXPORT uncompress (Byte *dest, uLong *destLen, const unsigned char *source, uLong sourceLen) { z_stream stream; int err; - stream.next_in = (const Byte *)source; + stream.next_in = (const unsigned char *)source; stream.avail_in = (uInt)sourceLen; stream.next_out = dest; stream.avail_out = (uInt)*destLen; diff --git a/zconf.h.in b/zconf.h.in index d419dda3f..e919175f3 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -91,13 +91,13 @@ # define ZEXPORTVA #endif -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif +/* Fallback for something that includes us. */ +#define Byte unsigned char +#define Bytef unsigned char + typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ -typedef Byte Bytef; typedef char charf; typedef int intf; typedef uInt uIntf; diff --git a/zlib.h b/zlib.h index f0a1eceb5..442ed8cbd 100644 --- a/zlib.h +++ b/zlib.h @@ -91,11 +91,11 @@ typedef void (*free_func) (void *opaque, void *address); struct internal_state; typedef struct z_stream_s { - const Byte *next_in; /* next input byte */ + const unsigned char *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 */ - Byte *next_out; /* next output byte should be put there */ + unsigned char *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 */ @@ -122,12 +122,12 @@ typedef struct gz_header_s { uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ - Byte *extra; /* pointer to extra field or Z_NULL if none */ + unsigned char *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) */ - Byte *name; /* pointer to zero-terminated file name or Z_NULL */ + unsigned char *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ - Byte *comment; /* pointer to zero-terminated comment or Z_NULL */ + unsigned char *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 @@ -584,7 +584,7 @@ ZEXTERN int ZEXPORT deflateInit2 (z_stream *strm, */ ZEXTERN int ZEXPORT deflateSetDictionary (z_stream *strm, - const Byte *dictionary, + const unsigned char *dictionary, uInt dictLength); /* Initializes the compression dictionary from the given byte sequence @@ -816,7 +816,7 @@ ZEXTERN int ZEXPORT inflateInit2 (z_stream *strm, */ ZEXTERN int ZEXPORT inflateSetDictionary (z_stream *strm, - const Byte *dictionary, + const unsigned char *dictionary, uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte @@ -839,7 +839,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary (z_stream *strm, */ ZEXTERN int ZEXPORT inflateGetDictionary (z_stream *strm, - Byte *dictionary, + unsigned char *dictionary, uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is @@ -1155,8 +1155,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags (void); you need special options. */ -ZEXTERN int ZEXPORT compress (Byte *dest, uLong *destLen, - const Byte *source, uLong sourceLen); +ZEXTERN int ZEXPORT compress (unsigned char *dest, uLong *destLen, + const unsigned char *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 @@ -1169,8 +1169,8 @@ ZEXTERN int ZEXPORT compress (Byte *dest, uLong *destLen, buffer. */ -ZEXTERN int ZEXPORT compress2 (Byte *dest, uLong *destLen, - const Byte *source, uLong sourceLen, +ZEXTERN int ZEXPORT compress2 (unsigned char *dest, uLong *destLen, + const unsigned char *source, uLong sourceLen, int level); /* Compresses the source buffer into the destination buffer. The level @@ -1192,8 +1192,8 @@ ZEXTERN uLong ZEXPORT compressBound (uLong sourceLen); compress() or compress2() call to allocate the destination buffer. */ -ZEXTERN int ZEXPORT uncompress (Byte *dest, uLong *destLen, - const Byte *source, uLong sourceLen); +ZEXTERN int ZEXPORT uncompress (unsigned char *dest, uLong *destLen, + const unsigned char *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 @@ -1564,7 +1564,7 @@ ZEXTERN void ZEXPORT gzclearerr (gzFile file); library. */ -ZEXTERN uint32_t ZEXPORT adler32 (uint32_t adler, const Byte *buf, uInt len); +ZEXTERN uint32_t ZEXPORT adler32 (uint32_t adler, const unsigned char *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 @@ -1595,7 +1595,7 @@ ZEXTERN uint32_t ZEXPORT adler32_combine (uint32_t adler1, uint32_t adler2, negative, the result has no meaning or utility. */ -ZEXTERN uint32_t ZEXPORT crc32 (uint32_t crc, const Byte *buf, uInt len); +ZEXTERN uint32_t ZEXPORT crc32 (uint32_t crc, const unsigned char *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