Changeset View
Changeset View
Standalone View
Standalone View
head/sys/contrib/zlib/deflate.c
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ | ||||
match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ | match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ | ||||
s->head[s->ins_h] = (Pos)(str)) | s->head[s->ins_h] = (Pos)(str)) | ||||
#endif | #endif | ||||
/* =========================================================================== | /* =========================================================================== | ||||
* Initialize the hash table (avoiding 64K overflow for 16 bit systems). | * Initialize the hash table (avoiding 64K overflow for 16 bit systems). | ||||
* prev[] will be initialized on the fly. | * prev[] will be initialized on the fly. | ||||
*/ | */ | ||||
#define CLEAR_HASH(s) \ | #define CLEAR_HASH(s) do { \ | ||||
s->head[s->hash_size-1] = NIL; \ | s->head[s->hash_size-1] = NIL; \ | ||||
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); | zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); \ | ||||
} while (0) | |||||
/* =========================================================================== | /* =========================================================================== | ||||
* Slide the hash table when sliding the window down (could be avoided with 32 | * Slide the hash table when sliding the window down (could be avoided with 32 | ||||
* bit values at the expense of memory usage). We slide even when level == 0 to | * bit values at the expense of memory usage). We slide even when level == 0 to | ||||
* keep the hash table consistent if we switch back to level > 0 later. | * keep the hash table consistent if we switch back to level > 0 later. | ||||
*/ | */ | ||||
local void slide_hash(s) | local void slide_hash(s) | ||||
deflate_state *s; | deflate_state *s; | ||||
▲ Show 20 Lines • Show All 1,414 Lines • ▼ Show 20 Lines | |||||
#define FLUSH_BLOCK(s, last) { \ | #define FLUSH_BLOCK(s, last) { \ | ||||
FLUSH_BLOCK_ONLY(s, last); \ | FLUSH_BLOCK_ONLY(s, last); \ | ||||
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ | if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ | ||||
} | } | ||||
/* Maximum stored block length in deflate format (not including header). */ | /* Maximum stored block length in deflate format (not including header). */ | ||||
#define MAX_STORED 65535 | #define MAX_STORED 65535 | ||||
#if !defined(MIN) | |||||
/* Minimum of a and b. */ | /* Minimum of a and b. */ | ||||
#define MIN(a, b) ((a) > (b) ? (b) : (a)) | #define MIN(a, b) ((a) > (b) ? (b) : (a)) | ||||
#endif | |||||
/* =========================================================================== | /* =========================================================================== | ||||
* Copy without compression as much as possible from the input stream, return | * Copy without compression as much as possible from the input stream, return | ||||
* the current block state. | * the current block state. | ||||
* | * | ||||
* In case deflateParams() is used to later switch to a non-zero compression | * In case deflateParams() is used to later switch to a non-zero compression | ||||
* level, s->matches (otherwise unused when storing) keeps track of the number | * level, s->matches (otherwise unused when storing) keeps track of the number | ||||
* of hash table slides to perform. If s->matches is 1, then one hash table | * of hash table slides to perform. If s->matches is 1, then one hash table | ||||
▲ Show 20 Lines • Show All 529 Lines • Show Last 20 Lines |