]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Kill Byte and Bytef
authorDaniel Axtens <dja@axtens.net>
Fri, 8 May 2015 11:46:51 +0000 (21:46 +1000)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Sun, 17 May 2015 16:11:59 +0000 (18:11 +0200)
Signed-off-by: Daniel Axtens <dja@axtens.net>
Conflicts:
adler32.c
compress.c
deflate.c
inflate.c
match.c
test/example.c
uncompr.c
zlib.h

14 files changed:
adler32.c
arch/x86/fill_window_sse.c
compress.c
crc32.c
deflate.c
deflate.h
gzwrite.c
inflate.c
match.c
test/example.c
trees.c
uncompr.c
zconf.h.in
zlib.h

index bbd03efac643787525c6f1af64889ad42c8dbb13..7cded1d2518c42343db3cff9ea9fd72b420ccbe4 100644 (file)
--- 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;
index 89a33cf8be045c33f8bf7a90b5b65f89ecb0e04c..70c6ca9cc1532060f4580d829bdf1ec78e75d343 100644 (file)
@@ -13,7 +13,7 @@
 #include <immintrin.h>
 #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)
 {
index d2e8459cb4b0ca234df2787fc17cf295be66f999..9af08d0451cb6d1bd518ab0ffdbd083d294f5a05 100644 (file)
    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 e4fe6c57ebd68c6c6ba2a0382bd779317089d56b..66d6858802a4cd10bed1fc41fbbf58002bcebb89 100644 (file)
--- 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) {
index fe4995f6528362ed455bab985676833ea59a9f7e..9861a7fa8dad15fc1006342a197692493099a6ed 100644 (file)
--- 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
index a76a94dfa8310dff232704bfe29a8ade79d29092..ef974c3735e14c252451d343474407746f19e223 100644 (file)
--- 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
index 5e4b3a14c6d0d3d2a7547c34bd66e518c9a8e48b..90811fb0c8538089ad879f883ae227b6ff9019a1 100644 (file)
--- 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;
index cf3959dc298585a9672496ffd853155c2cdeb5ee..a3a342f97073575d51d2c5d8385f7d45b0b543f4 100644 (file)
--- 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 d76a5d0a83de80a50189810fa66d2cf8f531452d..7a58b27633d7ef84626d7c21aa9f3eb9f4bf1131 100644 (file)
--- 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;
index a448b7e24416931ecca9bd360708db6e819e5f0c..a9b730ea5f275bbca3a09780e26722cefe5bb0e3 100644 (file)
@@ -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 c735f008ab3ebf43efe6be4712993dc48144d02f..a02bab7d12afc61b694475a26fd320fcbd0cffef 100644 (file)
--- 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;
index 59d44b22ba5e40dcce1dc8167d4603c29941077c..556b8678dc0056560a8889115c47475c84545c11 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
    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;
index d419dda3f5bb4661f5d9a64ca7cf8a34d7279816..e919175f3490e6590ad869b2cc04e83bd6a978bb 100644 (file)
 #  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 f0a1eceb53312c32baeb6e2f016bfd2a3b668501..442ed8cbdb9907a68dd0aa9f94365fec5ea089d2 100644 (file)
--- 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