From: Mika Lindqvist Date: Fri, 22 May 2015 22:17:27 +0000 (+0300) Subject: Cleanup user-defined types for 'unsigned char' X-Git-Tag: 1.9.9-b1~809^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F36%2Fhead;p=thirdparty%2Fzlib-ng.git Cleanup user-defined types for 'unsigned char' * Change 'uch' to 'unsigned char' * Change 'Byte' to 'unsigned char' --- diff --git a/deflate.c b/deflate.c index ae4ae10e..4bfe231a 100644 --- a/deflate.c +++ b/deflate.c @@ -331,7 +331,7 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ overlay = (uint16_t *) ZALLOC(strm, s->lit_bufsize, sizeof(uint16_t)+2); - s->pending_buf = (uch *) overlay; + s->pending_buf = (unsigned char *) overlay; s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(uint16_t)+2L); if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || @@ -1041,7 +1041,7 @@ int ZEXPORT deflateCopy (z_stream *dest, z_stream *source) ds->prev = (Pos *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Pos *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); overlay = (uint16_t *) ZALLOC(dest, ds->lit_bufsize, sizeof(uint16_t)+2); - ds->pending_buf = (uch *) overlay; + ds->pending_buf = (unsigned char *) overlay; if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { diff --git a/deflate.h b/deflate.h index ce09d087..baf7bf12 100644 --- a/deflate.h +++ b/deflate.h @@ -220,11 +220,11 @@ typedef struct internal_state { * The same heap array is used to build all trees. */ - uch depth[2*L_CODES+1]; + unsigned char depth[2*L_CODES+1]; /* Depth of each subtree used as tie breaker for trees of equal frequency */ - uch *l_buf; /* buffer for literals or lengths */ + unsigned char *l_buf; /* buffer for literals or lengths */ uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -314,8 +314,8 @@ typedef enum { } #else #define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((uint16_t)(w) >> 8)); \ + put_byte(s, (unsigned char)((w) & 0xff)); \ + put_byte(s, (unsigned char)((uint16_t)(w) >> 8)); \ } #endif @@ -353,22 +353,22 @@ void ZLIB_INTERNAL bi_windup (deflate_state *s); /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; + extern unsigned char ZLIB_INTERNAL _length_code[]; + extern unsigned char ZLIB_INTERNAL _dist_code[]; #else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; + extern const unsigned char ZLIB_INTERNAL _length_code[]; + extern const unsigned char ZLIB_INTERNAL _dist_code[]; #endif # define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ + { unsigned char cc = (c); \ s->d_buf[s->last_lit] = 0; \ s->l_buf[s->last_lit++] = cc; \ s->dyn_ltree[cc].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \ } # define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ + { unsigned char len = (length); \ uint16_t dist = (distance); \ s->d_buf[s->last_lit] = dist; \ s->l_buf[s->last_lit++] = len; \ diff --git a/test/example.c b/test/example.c index 4d232cf5..7ff64c80 100644 --- a/test/example.c +++ b/test/example.c @@ -71,7 +71,7 @@ void test_compress(unsigned char *compr, uLong comprLen, unsigned char *uncompr, #ifdef WITH_GZFILEOP void test_gzio (const char *fname, - Byte *uncompr, uLong uncomprLen); + unsigned char *uncompr, uLong uncomprLen); /* =========================================================================== * Test read/write of .gz files diff --git a/trees.c b/trees.c index 0349f5c2..518c24f2 100644 --- a/trees.c +++ b/trees.c @@ -65,7 +65,7 @@ local const int extra_dbits[D_CODES] /* extra bits for each distance code */ local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; -local const uch bl_order[BL_CODES] +local const unsigned char bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; /* The lengths of the bit length codes are sent in order of decreasing * probability, to avoid transmitting the lengths for unused bit length codes. @@ -183,7 +183,7 @@ local void tr_static_init() for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; for (n = 0; n < (1< dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { base_dist[code] = dist; for (n = 0; n < (1<depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); + s->depth[node] = (unsigned char)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); tree[n].Dad = tree[m].Dad = (uint16_t)node; #ifdef DUMP_BL_TREE if (tree == s->bl_tree) { @@ -922,7 +922,7 @@ 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] = (uint16_t)dist; - s->l_buf[s->last_lit++] = (uch)lc; + s->l_buf[s->last_lit++] = (unsigned char)lc; if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; diff --git a/trees.h b/trees.h index 9a4ce94d..777e1bb1 100644 --- a/trees.h +++ b/trees.h @@ -70,7 +70,7 @@ local const ct_data static_dtree[D_CODES] = { {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} }; -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { +const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, @@ -99,7 +99,7 @@ const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { +const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, diff --git a/uncompr.c b/uncompr.c index 556b8678..2a3eee48 100644 --- a/uncompr.c +++ b/uncompr.c @@ -21,7 +21,7 @@ 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 unsigned char *source, uLong sourceLen) +int ZEXPORT uncompress (unsigned char *dest, uLong *destLen, const unsigned char *source, uLong sourceLen) { z_stream stream; int err;