From: Nathan Moinvaziri Date: Thu, 18 Jul 2019 11:21:13 +0000 (-0700) Subject: Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363) X-Git-Tag: 1.9.9-b1~465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f06c71f9817700eccb507f54249a8c52335bf693;p=thirdparty%2Fzlib-ng.git Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363) --- diff --git a/deflate.c b/deflate.c index 05480f5f9..908cb01e1 100644 --- a/deflate.c +++ b/deflate.c @@ -55,7 +55,7 @@ #include "match_p.h" #include "functable.h" -const char deflate_copyright[] = " deflate 1.2.11.f Copyright 1995-2016 Jean-loup Gailly and Mark Adler "; +const char zng_deflate_copyright[] = " deflate 1.2.11.f Copyright 1995-2016 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -281,11 +281,11 @@ int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method, strm->msg = NULL; if (strm->zalloc == NULL) { - strm->zalloc = zcalloc; + strm->zalloc = zng_calloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zcfree; + strm->zfree = zng_cfree; if (level == Z_DEFAULT_COMPRESSION) level = 6; @@ -550,7 +550,7 @@ int ZEXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { strm->adler = functable.adler32(0L, NULL, 0); s->last_flush = -2; - _tr_init(s); + zng_tr_init(s); DEFLATE_RESET_KEEP_HOOK(strm); /* hook for IBM Z DFLTCC */ @@ -603,7 +603,7 @@ int ZEXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int bits, int value) { put = bits; s->bi_buf |= (uint16_t)((value & ((1 << put) - 1)) << s->bi_valid); s->bi_valid += put; - _tr_flush_bits(s); + zng_tr_flush_bits(s); value >>= put; bits -= put; } while (bits); @@ -765,7 +765,7 @@ ZLIB_INTERNAL void flush_pending(PREFIX3(stream) *strm) { uint32_t len; deflate_state *s = strm->state; - _tr_flush_bits(s); + zng_tr_flush_bits(s); len = s->pending; if (len > strm->avail_out) len = strm->avail_out; @@ -1053,9 +1053,9 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) { } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); + zng_tr_align(s); } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); + zng_tr_stored_block(s, (char*)0, 0L, 0); /* For a full flush, this empty block will be recognized * as a special marker by inflate_sync(). */ @@ -1444,7 +1444,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { * including any pending bits. This also updates the debugging counts. */ last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; - _tr_stored_block(s, (char *)0, 0L, last); + zng_tr_stored_block(s, (char *)0, 0L, last); /* Replace the lengths in the dummy stored block with len. */ s->pending_buf[s->pending - 4] = len; @@ -1568,7 +1568,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { len = MIN(left, have); last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0; - _tr_stored_block(s, (char *)s->window + s->block_start, len, last); + zng_tr_stored_block(s, (char *)s->window + s->block_start, len, last); s->block_start += len; flush_pending(s->strm); } @@ -1626,7 +1626,7 @@ static block_state deflate_rle(deflate_state *s, int flush) { if (s->match_length >= MIN_MATCH) { check_match(s, s->strstart, s->strstart - 1, s->match_length); - _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); + zng_tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); s->lookahead -= s->match_length; s->strstart += s->match_length; @@ -1634,7 +1634,7 @@ static block_state deflate_rle(deflate_state *s, int flush) { } else { /* No match, output a literal byte */ Tracevv((stderr, "%c", s->window[s->strstart])); - _tr_tally_lit(s, s->window[s->strstart], bflush); + zng_tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } @@ -1672,7 +1672,7 @@ static block_state deflate_huff(deflate_state *s, int flush) { /* Output a literal byte */ s->match_length = 0; Tracevv((stderr, "%c", s->window[s->strstart])); - _tr_tally_lit(s, s->window[s->strstart], bflush); + zng_tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; if (bflush) diff --git a/deflate.h b/deflate.h index c512a3f1a..3310d5c58 100644 --- a/deflate.h +++ b/deflate.h @@ -332,19 +332,19 @@ static inline void put_short(deflate_state *s, uint16_t w) { void ZLIB_INTERNAL fill_window_c(deflate_state *s); /* in trees.c */ -void ZLIB_INTERNAL _tr_init(deflate_state *s); -int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); -void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last); -void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); -void ZLIB_INTERNAL _tr_align(deflate_state *s); -void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last); +void ZLIB_INTERNAL zng_tr_init(deflate_state *s); +int ZLIB_INTERNAL zng_tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last); +void ZLIB_INTERNAL zng_tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL zng_tr_align(deflate_state *s); +void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last); void ZLIB_INTERNAL bi_windup(deflate_state *s); unsigned ZLIB_INTERNAL bi_reverse(unsigned code, int len); void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm); -#define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never + * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never * used. */ @@ -352,14 +352,14 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm); /* Inline versions of _tr_tally for speed: */ # if defined(GEN_TREES_H) - extern unsigned char ZLIB_INTERNAL _length_code[]; - extern unsigned char ZLIB_INTERNAL _dist_code[]; + extern unsigned char ZLIB_INTERNAL zng_length_code[]; + extern unsigned char ZLIB_INTERNAL zng_dist_code[]; # else - extern const unsigned char ZLIB_INTERNAL _length_code[]; - extern const unsigned char ZLIB_INTERNAL _dist_code[]; + extern const unsigned char ZLIB_INTERNAL zng_length_code[]; + extern const unsigned char ZLIB_INTERNAL zng_dist_code[]; # endif -# define _tr_tally_lit(s, c, flush) \ +# define zng_tr_tally_lit(s, c, flush) \ { unsigned char cc = (c); \ s->sym_buf[s->sym_next++] = 0; \ s->sym_buf[s->sym_next++] = 0; \ @@ -367,21 +367,21 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm); s->dyn_ltree[cc].Freq++; \ flush = (s->sym_next == s->sym_end); \ } -# define _tr_tally_dist(s, distance, length, flush) \ +# define zng_tr_tally_dist(s, distance, length, flush) \ { unsigned char len = (unsigned char)(length); \ uint16_t dist = (uint16_t)(distance); \ s->sym_buf[s->sym_next++] = dist; \ s->sym_buf[s->sym_next++] = dist >> 8; \ s->sym_buf[s->sym_next++] = len; \ dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_ltree[zng_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->sym_next == s->sym_end); \ } #else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, (unsigned)(distance), (unsigned)(length)) +# define zng_tr_tally_lit(s, c, flush) flush = zng_tr_tally(s, 0, c) +# define zng_tr_tally_dist(s, distance, length, flush) \ + flush = zng_tr_tally(s, (unsigned)(distance), (unsigned)(length)) #endif /* =========================================================================== diff --git a/deflate_fast.c b/deflate_fast.c index 07f29f396..47e1d5b0a 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -58,7 +58,7 @@ ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { if (s->match_length >= MIN_MATCH) { check_match(s, s->strstart, s->match_start, s->match_length); - _tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush); + zng_tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush); s->lookahead -= s->match_length; @@ -102,7 +102,7 @@ ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { } else { /* No match, output a literal byte */ Tracevv((stderr, "%c", s->window[s->strstart])); - _tr_tally_lit(s, s->window[s->strstart], bflush); + zng_tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } diff --git a/deflate_medium.c b/deflate_medium.c index c23936ed5..07dbf2af5 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -23,11 +23,11 @@ struct match { #define MAX_DIST2 ((1 << MAX_WBITS) - MIN_LOOKAHEAD) static int tr_tally_dist(deflate_state *s, int distance, int length) { - return _tr_tally(s, distance, length); + return zng_tr_tally(s, distance, length); } static int tr_tally_lit(deflate_state *s, int c) { - return _tr_tally(s, 0, c); + return zng_tr_tally(s, 0, c); } static int emit_match(deflate_state *s, struct match match) { diff --git a/deflate_p.h b/deflate_p.h index 69a7c82a0..b282baece 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -52,7 +52,7 @@ static inline Pos insert_string_c(deflate_state *const s, const Pos str, unsigne * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK_ONLY(s, last) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ + zng_tr_flush_block(s, (s->block_start >= 0L ? \ (char *)&s->window[(unsigned)s->block_start] : \ NULL), \ (unsigned long)((long)s->strstart - s->block_start), \ diff --git a/deflate_slow.c b/deflate_slow.c index f4c8af769..7cb9c70f8 100644 --- a/deflate_slow.c +++ b/deflate_slow.c @@ -86,7 +86,7 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { check_match(s, s->strstart-1, s->prev_match, s->prev_length); - _tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); + zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not @@ -130,7 +130,7 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { * is longer, truncate the previous match to a single literal. */ Tracevv((stderr, "%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); + zng_tr_tally_lit(s, s->window[s->strstart-1], bflush); if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } @@ -150,7 +150,7 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { Assert(flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { Tracevv((stderr, "%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); + zng_tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; diff --git a/infback.c b/infback.c index b4fb562b1..1dfc34b78 100644 --- a/infback.c +++ b/infback.c @@ -36,11 +36,11 @@ int ZEXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int windowBits, unsi return Z_STREAM_ERROR; strm->msg = NULL; /* in case we return an error */ if (strm->zalloc == NULL) { - strm->zalloc = zcalloc; + strm->zalloc = zng_calloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zcfree; + strm->zfree = zng_cfree; state = (struct inflate_state *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == NULL) return Z_MEM_ERROR; @@ -85,14 +85,14 @@ static void fixedtables(struct inflate_state *state) { next = fixed; lenfix = next; bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + zng_inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + zng_inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; @@ -361,7 +361,7 @@ int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc state->next = state->codes; state->lencode = (code const *)(state->next); state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); + ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; @@ -433,7 +433,7 @@ int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc state->next = state->codes; state->lencode = (code const *)(state->next); state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); + ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; @@ -441,7 +441,7 @@ int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc } state->distcode = (code const *)(state->next); state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; @@ -458,7 +458,7 @@ int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc RESTORE(); if (state->whave < state->wsize) state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); + zng_inflate_fast(strm, state->wsize); LOAD(); break; } diff --git a/inffast.c b/inffast.c index bd9b2a1c4..23edb08de 100644 --- a/inffast.c +++ b/inffast.c @@ -60,7 +60,7 @@ requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { +void ZLIB_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { /* start: inflate()'s starting value for strm->avail_out */ struct inflate_state *state; const unsigned char *in; /* local strm->next_in */ diff --git a/inffast.h b/inffast.h index 9ad21abc8..94ffc2fc9 100644 --- a/inffast.h +++ b/inffast.h @@ -10,7 +10,7 @@ subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start); +void ZLIB_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start); #define INFLATE_FAST_MIN_HAVE 8 #define INFLATE_FAST_MIN_LEFT 258 diff --git a/inflate.c b/inflate.c index 8a8d328f9..f386f64ce 100644 --- a/inflate.c +++ b/inflate.c @@ -227,11 +227,11 @@ int ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int windowBits, const c return Z_STREAM_ERROR; strm->msg = NULL; /* in case we return an error */ if (strm->zalloc == NULL) { - strm->zalloc = zcalloc; + strm->zalloc = zng_calloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zcfree; + strm->zfree = zng_cfree; state = (struct inflate_state *) ZALLOC_STATE(strm, 1, sizeof(struct inflate_state)); if (state == NULL) return Z_MEM_ERROR; @@ -302,14 +302,14 @@ static void fixedtables(struct inflate_state *state) { next = fixed; lenfix = next; bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + zng_inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + zng_inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; @@ -962,7 +962,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { state->next = state->codes; state->lencode = (const code *)(state->next); state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); + ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; @@ -1035,7 +1035,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { state->next = state->codes; state->lencode = (const code *)(state->next); state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); + ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; @@ -1043,7 +1043,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { } state->distcode = (const code *)(state->next); state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; @@ -1060,7 +1060,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_LEFT) { RESTORE(); - inflate_fast(strm, out); + zng_inflate_fast(strm, out); LOAD(); if (state->mode == TYPE) state->back = -1; diff --git a/inftrees.c b/inftrees.c index 51e85375c..6415f79d2 100644 --- a/inftrees.c +++ b/inftrees.c @@ -9,7 +9,7 @@ #define MAXBITS 15 -const char inflate_copyright[] = " inflate 1.2.11.f Copyright 1995-2016 Mark Adler "; +const char zng_inflate_copyright[] = " inflate 1.2.11.f Copyright 1995-2016 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -29,7 +29,7 @@ const char inflate_copyright[] = " inflate 1.2.11.f Copyright 1995-2016 Mark Adl 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(codetype type, uint16_t *lens, unsigned codes, +int ZLIB_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes, code * *table, unsigned *bits, uint16_t *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ diff --git a/inftrees.h b/inftrees.h index eaf3df1ca..8395e764e 100644 --- a/inftrees.h +++ b/inftrees.h @@ -60,7 +60,7 @@ typedef enum { DISTS } codetype; -int ZLIB_INTERNAL inflate_table (codetype type, uint16_t *lens, unsigned codes, +int ZLIB_INTERNAL zng_inflate_table (codetype type, uint16_t *lens, unsigned codes, code * *table, unsigned *bits, uint16_t *work); #endif /* INFTREES_H_ */ diff --git a/trees.c b/trees.c index 53c73bde1..ddb34ef7d 100644 --- a/trees.c +++ b/trees.c @@ -84,7 +84,7 @@ static const unsigned char bl_order[BL_CODES] ZLIB_INTERNAL ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * The codes 286 and 287 are needed to build a canonical tree (see zng_tr_init * below). */ @@ -93,13 +93,13 @@ static ct_data static_dtree[D_CODES]; * 5 bits.) */ -unsigned char _dist_code[DIST_CODE_LEN]; +unsigned char zng_dist_code[DIST_CODE_LEN]; /* Distance codes. The first 256 values correspond to the distances * 3 .. 258, the last 256 values correspond to the top 8 bits of * the 15 bit distances. */ -unsigned char _length_code[MAX_MATCH-MIN_MATCH+1]; +unsigned char zng_length_code[MAX_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ static int base_length[LENGTH_CODES]; @@ -182,7 +182,7 @@ static void tr_static_init(void) { for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; for (n = 0; n < (1 << extra_lbits[code]); n++) { - _length_code[length++] = (unsigned char)code; + zng_length_code[length++] = (unsigned char)code; } } Assert(length == 256, "tr_static_init: length != 256"); @@ -190,14 +190,14 @@ static void tr_static_init(void) { * in two different ways: code 284 + 5 bits or code 285, so we * overwrite length_code[255] to use the best encoding: */ - _length_code[length-1] = (unsigned char)code; + zng_length_code[length-1] = (unsigned char)code; /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { base_dist[code] = dist; for (n = 0; n < (1 << extra_dbits[code]); n++) { - _dist_code[dist++] = (unsigned char)code; + zng_dist_code[dist++] = (unsigned char)code; } } Assert(dist == 256, "tr_static_init: dist != 256"); @@ -205,7 +205,7 @@ static void tr_static_init(void) { for ( ; code < D_CODES; code++) { base_dist[code] = dist << 7; for (n = 0; n < (1 << (extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (unsigned char)code; + zng_dist_code[256 + dist++] = (unsigned char)code; } } Assert(dist == 256, "tr_static_init: 256+dist != 512"); @@ -269,14 +269,14 @@ void gen_trees_header() { fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); } - fprintf(header, "const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); + fprintf(header, "const unsigned char ZLIB_INTERNAL zng_dist_code[DIST_CODE_LEN] = {\n"); for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); + fprintf(header, "%2u%s", zng_dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); } - fprintf(header, "const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + fprintf(header, "const unsigned char ZLIB_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + fprintf(header, "%2u%s", zng_length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); } fprintf(header, "static const int base_length[LENGTH_CODES] = {\n"); @@ -297,7 +297,7 @@ void gen_trees_header() { /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void ZLIB_INTERNAL _tr_init(deflate_state *s) { +void ZLIB_INTERNAL zng_tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; @@ -789,7 +789,7 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last) { +void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last) { /* buf: input block */ /* stored_len: length of input block */ /* last: one if this is the last block for a file */ @@ -811,7 +811,7 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long s /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { +void ZLIB_INTERNAL zng_tr_flush_bits(deflate_state *s) { bi_flush(s); } @@ -819,7 +819,7 @@ void ZLIB_INTERNAL _tr_flush_bits(deflate_state *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(deflate_state *s) { +void ZLIB_INTERNAL zng_tr_align(deflate_state *s) { send_bits(s, STATIC_TREES << 1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef ZLIB_DEBUG @@ -832,7 +832,7 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s) { * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last) { +void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, unsigned long 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 */ @@ -888,7 +888,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long st * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ - _tr_stored_block(s, buf, stored_len, last); + zng_tr_stored_block(s, buf, stored_len, last); #ifdef FORCE_STATIC } else if (static_lenb >= 0) { /* force static trees */ @@ -927,7 +927,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long st * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +int ZLIB_INTERNAL zng_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->sym_buf[s->sym_next++] = dist; @@ -942,9 +942,9 @@ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { dist--; /* dist = match distance - 1 */ Assert((uint16_t)dist < (uint16_t)MAX_DIST(s) && (uint16_t)lc <= (uint16_t)(MAX_MATCH-MIN_MATCH) && - (uint16_t)d_code(dist) < (uint16_t)D_CODES, "_tr_tally: bad match"); + (uint16_t)d_code(dist) < (uint16_t)D_CODES, "zng_tr_tally: bad match"); - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_ltree[zng_length_code[lc]+LITERALS+1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } return (s->sym_next == s->sym_end); @@ -972,7 +972,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data Tracecv(isgraph(lc), (stderr, " '%c' ", lc)); } else { /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; + code = zng_length_code[lc]; send_code(s, code+LITERALS+1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { diff --git a/trees.h b/trees.h index 6fc1c8485..d9300c65f 100644 --- a/trees.h +++ b/trees.h @@ -73,7 +73,7 @@ static const ct_data static_dtree[D_CODES] = { {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} }; -const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { +const unsigned char ZLIB_INTERNAL zng_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, @@ -102,7 +102,7 @@ const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; -const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { +const unsigned char ZLIB_INTERNAL zng_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/zutil.c b/zutil.c index 4373586bd..7553db82b 100644 --- a/zutil.c +++ b/zutil.c @@ -14,7 +14,7 @@ # include "malloc.h" #endif -const char * const z_errmsg[10] = { +const char * const zng_errmsg[10] = { (const char *)"need dictionary", /* Z_NEED_DICT 2 */ (const char *)"stream end", /* Z_STREAM_END 1 */ (const char *)"", /* Z_OK 0 */ @@ -120,7 +120,7 @@ const char * ZEXPORT PREFIX(zError)(int err) #ifndef MY_ZCALLOC /* Any system without a special alloc function */ -void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size) +void ZLIB_INTERNAL *zng_calloc (void *opaque, unsigned items, unsigned size) { (void)opaque; #ifndef UNALIGNED_OK @@ -131,7 +131,7 @@ void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size) #endif } -void ZLIB_INTERNAL zcfree (void *opaque, void *ptr) +void ZLIB_INTERNAL zng_cfree (void *opaque, void *ptr) { (void)opaque; free(ptr); diff --git a/zutil.h b/zutil.h index 8d8ae92ee..e34caddea 100644 --- a/zutil.h +++ b/zutil.h @@ -34,10 +34,10 @@ typedef unsigned char uch; /* Included for compatibility with external code only typedef uint16_t ush; /* Included for compatibility with external code only */ typedef unsigned long ulg; -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) zng_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ @@ -159,8 +159,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define Tracecv(c, x) #endif -void ZLIB_INTERNAL *zcalloc(void *opaque, unsigned items, unsigned size); -void ZLIB_INTERNAL zcfree(void *opaque, void *ptr); +void ZLIB_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size); +void ZLIB_INTERNAL zng_cfree(void *opaque, void *ptr); #define ZALLOC(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (void *)(addr))