From: Nathan Moinvaziri Date: Thu, 28 May 2020 18:15:59 +0000 (-0700) Subject: Use a constant to load adler-32 initial hash value. X-Git-Tag: 1.9.9-b1~279 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0dbcace5d16b6fbee02a0c5f64acb160589eeaa;p=thirdparty%2Fzlib-ng.git Use a constant to load adler-32 initial hash value. --- diff --git a/deflate.c b/deflate.c index 8dc6d35c6..138f02ae5 100644 --- a/deflate.c +++ b/deflate.c @@ -539,7 +539,7 @@ int ZEXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { crc_reset(s); else #endif - strm->adler = functable.adler32(0L, NULL, 0); + strm->adler = ADLER32_INITIAL_VALUE; s->last_flush = -2; zng_tr_init(s); @@ -848,7 +848,7 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) { if (s->strstart != 0) { put_uint32_msb(s, strm->adler); } - strm->adler = functable.adler32(0L, NULL, 0); + strm->adler = ADLER32_INITIAL_VALUE; s->status = BUSY_STATE; /* Compression must start with an empty pending buffer */ diff --git a/inflate.c b/inflate.c index 9ccb0de92..59fcd831b 100644 --- a/inflate.c +++ b/inflate.c @@ -64,7 +64,7 @@ int ZEXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { if (state->wrap) /* to support ill-conceived Java test suite */ strm->adler = state->wrap & 1; state->mode = HEAD; - state->check = functable.adler32(0L, NULL, 0); + state->check = ADLER32_INITIAL_VALUE; state->last = 0; state->havedict = 0; state->flags = -1; @@ -448,7 +448,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { state->dmax = 1U << len; state->flags = 0; /* indicate zlib header */ Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = functable.adler32(0L, NULL, 0); + strm->adler = state->check = ADLER32_INITIAL_VALUE; state->mode = hold & 0x200 ? DICTID : TYPE; INITBITS(); break; @@ -604,7 +604,7 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { RESTORE(); return Z_NEED_DICT; } - strm->adler = state->check = functable.adler32(0L, NULL, 0); + strm->adler = state->check = ADLER32_INITIAL_VALUE; state->mode = TYPE; case TYPE: @@ -1143,8 +1143,7 @@ int ZEXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const unsigned c /* check for correct dictionary identifier */ if (state->mode == DICT) { - dictid = functable.adler32(0L, NULL, 0); - dictid = functable.adler32(dictid, dictionary, dictLength); + dictid = functable.adler32(ADLER32_INITIAL_VALUE, dictionary, dictLength); if (dictid != state->check) return Z_DATA_ERROR; } diff --git a/zutil.h b/zutil.h index 457b47ca2..0c9accb53 100644 --- a/zutil.h +++ b/zutil.h @@ -65,6 +65,8 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ +#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */ + /* target dependencies */ #ifdef AMIGA