if (strm->avail_in == 0 && !param->cf)
return DFLTCC_INFLATE_BREAK;
- if (PREFIX(inflate_ensure_window)(state)) {
- state->mode = MEM;
- return DFLTCC_INFLATE_CONTINUE;
- }
+ /* if window not in use yet, initialize */
+ if (state->wsize == 0)
+ state->wsize = 1U << state->wbits;
/* Translate stream to parameter block */
param->cvt = ((state->wrap & 4) && state->flags) ? CVT_CRC32 : CVT_ADLER32;
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_param_v0 *param = &state->arch.common.param;
- if (PREFIX(inflate_ensure_window)(state)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
+ /* if window not in use yet, initialize */
+ if (state->wsize == 0)
+ state->wsize = 1U << state->wbits;
append_history(param, state->window, dictionary, dict_length);
state->havedict = 1;
/* function prototypes */
static int inflateStateCheck(PREFIX3(stream) *strm);
-static int updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t len, int32_t cksum);
+static void updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t len, int32_t cksum);
static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len);
static inline void inf_chksum_cpy(PREFIX3(stream) *strm, uint8_t *dst,
state->distbits = 5;
}
-int Z_INTERNAL PREFIX(inflate_ensure_window)(struct inflate_state *state) {
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->wnext = 0;
- state->whave = 0;
- }
-
- return Z_OK;
-}
-
/*
Update the window with the last wsize (normally 32K) bytes written before
returning. If window does not exist yet, create it. This is only called
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
-static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t len, int32_t cksum) {
+static void updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t len, int32_t cksum) {
struct inflate_state *state;
uint32_t dist;
state = (struct inflate_state *)strm->state;
- if (PREFIX(inflate_ensure_window)(state)) return 1;
+ /* if window not in use yet, initialize */
+ if (state->wsize == 0)
+ state->wsize = 1U << state->wbits;
/* len state->wsize or less output bytes into the circular window */
if (len >= state->wsize) {
state->whave += dist;
}
}
- return 0;
}
/*
ret = Z_DATA_ERROR;
goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
-
case SYNC:
default: /* can't happen, but makes compilers happy */
Return from inflate(), updating the total counts and the check value.
If there was no progress during the inflate() call, return a buffer
error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
*/
inf_leave:
RESTORE();
(state->wsize || (out != strm->avail_out && state->mode < BAD &&
(state->mode < CHECK || flush != Z_FINISH)))) {
/* update sliding window with respective checksum if not in "raw" mode */
- if (updatewindow(strm, strm->next_out, check_bytes, state->wrap & 4)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
+ updatewindow(strm, strm->next_out, check_bytes, state->wrap & 4);
}
in -= strm->avail_in;
out -= strm->avail_out;
int32_t Z_EXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const uint8_t *dictionary, uint32_t dictLength) {
struct inflate_state *state;
unsigned long dictid;
- int32_t ret;
/* check state */
if (inflateStateCheck(strm))
/* copy dictionary to window using updatewindow(), which will amend the
existing dictionary if appropriate */
- ret = updatewindow(strm, dictionary + dictLength, dictLength, 0);
- if (ret) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
+ updatewindow(strm, dictionary + dictLength, dictLength, 0);
+
state->havedict = 1;
Tracev((stderr, "inflate: dictionary set\n"));
return Z_OK;
LENGTH, /* i: waiting for 32-bit length (gzip) */
DONE, /* finished check, done -- remain here until reset */
BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
SYNC /* looking for synchronization bytes to restart inflate() */
} inflate_mode;
/*
State transitions between above modes -
- (most modes can go to BAD or MEM on error -- not shown for clarity)
+ (most modes can go to BAD on error -- not shown for clarity)
Process header:
HEAD -> (gzip) or (zlib) or (raw)
#endif
};
-int Z_INTERNAL PREFIX(inflate_ensure_window)(struct inflate_state *state);
void Z_INTERNAL PREFIX(fixedtables)(struct inflate_state *state);
Z_INTERNAL inflate_allocs* alloc_inflate(PREFIX3(stream) *strm);
Z_INTERNAL void free_inflate(PREFIX3(stream) *strm);