diff options
author | Hans Kristian Rosbach <hk-git@circlestorm.org> | 2020-08-21 15:53:30 +0200 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-08-23 09:57:45 +0200 |
commit | e7bb6db09a183807a8f94a8bdcf156a765402d9f (patch) | |
tree | cd4fdc2df803849944f2c2e544a82bb61c27d386 /deflate.c | |
parent | 18ecfceb65862929206f50a20c649c81d3858bfd (diff) |
Replace hash_bits, hash_size and hash_mask with defines.
Diffstat (limited to 'deflate.c')
-rw-r--r-- | deflate.c | 28 |
1 files changed, 8 insertions, 20 deletions
@@ -180,12 +180,10 @@ static const config configuration_table[10] = { /* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. + * Initialize the hash table. prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) do { \ - s->head[s->hash_size - 1] = NIL; \ - memset((unsigned char *)s->head, 0, (unsigned)(s->hash_size - 1) * sizeof(*s->head)); \ + memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \ } while (0) /* =========================================================================== @@ -194,11 +192,11 @@ static const config configuration_table[10] = { * keep the hash table consistent if we switch back to level > 0 later. */ ZLIB_INTERNAL void slide_hash_c(deflate_state *s) { - unsigned n; Pos *p; + unsigned n; unsigned int wsize = s->w_size; - n = s->hash_size; + n = HASH_SIZE; p = &s->head[n]; #ifdef NOT_TWEAK_COMPILER do { @@ -322,16 +320,6 @@ int32_t ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int3 s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; -#ifdef X86_SSE42_CRC_HASH - if (x86_cpu_has_sse42) - s->hash_bits = (unsigned int)15; - else -#endif - s->hash_bits = (unsigned int)memLevel + 7; - - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - #ifdef X86_PCLMULQDQ_CRC window_padding = 8; #endif @@ -339,7 +327,7 @@ int32_t ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int3 s->window = (unsigned char *) ZALLOC_WINDOW(strm, s->w_size + window_padding, 2*sizeof(unsigned char)); s->prev = (Pos *) ZALLOC(strm, s->w_size, sizeof(Pos)); memset(s->prev, 0, s->w_size * sizeof(Pos)); - s->head = (Pos *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + s->head = (Pos *) ZALLOC(strm, HASH_SIZE, sizeof(Pos)); s->high_water = 0; /* nothing written to s->window yet */ @@ -738,7 +726,7 @@ unsigned long ZEXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long /* if not default parameters, return conservative bound */ if (DEFLATE_NEED_CONSERVATIVE_BOUND(strm) || /* hook for IBM Z DFLTCC */ - s->w_bits != 15 || s->hash_bits != 8 + 7) + s->w_bits != 15 || HASH_BITS < 15) return complen + wraplen; /* default settings: return tight bound for that case */ @@ -1133,7 +1121,7 @@ int32_t ZEXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sour ds->window = (unsigned char *) ZALLOC_WINDOW(dest, ds->w_size + window_padding, 2*sizeof(unsigned char)); ds->prev = (Pos *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Pos *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + ds->head = (Pos *) ZALLOC(dest, HASH_SIZE, sizeof(Pos)); ds->pending_buf = (unsigned char *) ZALLOC(dest, ds->lit_bufsize, 4); if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) { @@ -1143,7 +1131,7 @@ int32_t ZEXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sour 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((void *)ds->head, (void *)ss->head, HASH_SIZE * sizeof(Pos)); memcpy(ds->pending_buf, ss->pending_buf, (unsigned int)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |