diff options
Diffstat (limited to 'deflate.c')
-rw-r--r-- | deflate.c | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -47,7 +47,7 @@ | |||
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | 49 | ||
50 | /* $Id: deflate.c,v 1.5 1995/04/29 16:52:05 jloup Exp $ */ | 50 | /* $Id: deflate.c,v 1.6 1995/05/01 17:23:57 jloup Exp $ */ |
51 | 51 | ||
52 | #include "deflate.h" | 52 | #include "deflate.h" |
53 | 53 | ||
@@ -152,12 +152,20 @@ local void check_match __P((deflate_state *s, IPos start, IPos match, | |||
152 | s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ | 152 | s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ |
153 | s->head[s->ins_h] = (str)) | 153 | s->head[s->ins_h] = (str)) |
154 | 154 | ||
155 | /* =========================================================================== | ||
156 | * Initialize the hash table (avoiding 64K overflow for 16 bit systems). | ||
157 | * prev[] will be initialized on the fly. | ||
158 | */ | ||
159 | #define CLEAR_HASH(s) \ | ||
160 | s->head[s->hash_size-1] = NIL; \ | ||
161 | zmemzero((char*)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); | ||
162 | |||
155 | /* ========================================================================= */ | 163 | /* ========================================================================= */ |
156 | int deflateInit (strm, level) | 164 | int deflateInit (strm, level) |
157 | z_stream *strm; | 165 | z_stream *strm; |
158 | int level; | 166 | int level; |
159 | { | 167 | { |
160 | return deflateInit2 (strm, level, DEFLATED, WBITS, MEM_LEVEL, 0); | 168 | return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, 0); |
161 | /* To do: ignore strm->next_in if we use it as window */ | 169 | /* To do: ignore strm->next_in if we use it as window */ |
162 | } | 170 | } |
163 | 171 | ||
@@ -345,6 +353,13 @@ int deflate (strm, flush) | |||
345 | } else { | 353 | } else { |
346 | if (deflate_slow(strm->state, flush)) return Z_OK; | 354 | if (deflate_slow(strm->state, flush)) return Z_OK; |
347 | } | 355 | } |
356 | /* ??? remember Z_FULL_FLUSH if we didn't have enough space */ | ||
357 | if (flush == Z_FULL_FLUSH) { | ||
358 | ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */ | ||
359 | flush_pending(strm); | ||
360 | CLEAR_HASH(strm->state); /* forget history */ | ||
361 | if (strm->avail_out == 0) return Z_OK; | ||
362 | } | ||
348 | } | 363 | } |
349 | Assert(strm->avail_out > 0, "bug2"); | 364 | Assert(strm->avail_out > 0, "bug2"); |
350 | 365 | ||
@@ -435,12 +450,7 @@ local void lm_init (s) | |||
435 | 450 | ||
436 | s->window_size = (ulg)2L*s->w_size; | 451 | s->window_size = (ulg)2L*s->w_size; |
437 | 452 | ||
438 | 453 | CLEAR_HASH(s); | |
439 | /* Initialize the hash table (avoiding 64K overflow for 16 bit systems). | ||
440 | * prev[] will be initialized on the fly. | ||
441 | */ | ||
442 | s->head[s->hash_size-1] = NIL; | ||
443 | zmemzero((char*)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); | ||
444 | 454 | ||
445 | /* Set the default configuration parameters: | 455 | /* Set the default configuration parameters: |
446 | */ | 456 | */ |
@@ -930,8 +940,10 @@ local int deflate_slow(s, flush) | |||
930 | s->lookahead--; | 940 | s->lookahead--; |
931 | } | 941 | } |
932 | } | 942 | } |
933 | if (s->match_available) ct_tally (s, 0, s->window[s->strstart-1]); | 943 | if (s->match_available) { |
934 | 944 | ct_tally (s, 0, s->window[s->strstart-1]); | |
945 | s->match_available = 0; | ||
946 | } | ||
935 | FLUSH_BLOCK(s, flush == Z_FINISH); | 947 | FLUSH_BLOCK(s, flush == Z_FINISH); |
936 | return 0; | 948 | return 0; |
937 | } | 949 | } |