static block_state deflate_huff (deflate_state *s, int flush);
static void lm_init (deflate_state *s);
static void putShortMSB (deflate_state *s, uint16_t b);
-ZLIB_INTERNAL void flush_pending (PREFIX3(stream) *strm);
ZLIB_INTERNAL unsigned read_buf (PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
extern void crc_reset(deflate_state *const s);
void ZLIB_INTERNAL _tr_align(deflate_state *s);
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last);
void ZLIB_INTERNAL bi_windup(deflate_state *s);
+unsigned ZLIB_INTERNAL bi_reverse(unsigned code, int len);
+void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
#define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
}
#endif /* MAKEFIXED */
+int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state)
+{
+ /* if it hasn't been done already, allocate space for the window */
+ if (state->window == NULL) {
+#ifdef INFFAST_CHUNKSIZE
+ unsigned wsize = 1U << state->wbits;
+ state->window = (unsigned char *) ZALLOC(state->strm, wsize + INFFAST_CHUNKSIZE, sizeof(unsigned char));
+ if (state->window == Z_NULL)
+ return 1;
+ memset(state->window + wsize, 0, INFFAST_CHUNKSIZE);
+#else
+ state->window = (unsigned char *) ZALLOC(state->strm, 1U << state->wbits, sizeof(unsigned char));
+ if (state->window == NULL)
+ return 1;
+#endif
+ }
+
+ /* if window not in use yet, initialize */
+ if (state->wsize == 0) {
+ state->wsize = 1U << state->wbits;
+ state->wnext = 0;
+ state->whave = 0;
+ }
+
+ return 0;
+}
+
/*
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
state = (struct inflate_state *)strm->state;
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == NULL) {
-#ifdef INFFAST_CHUNKSIZE
- unsigned wsize = 1U << state->wbits;
- state->window = (unsigned char *) ZALLOC(strm, wsize + INFFAST_CHUNKSIZE, sizeof(unsigned char));
- if (state->window == Z_NULL)
- return 1;
- memset(state->window + wsize, 0, INFFAST_CHUNKSIZE);
-#else
- state->window = (unsigned char *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char));
- if (state->window == NULL)
- return 1;
-#endif
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->wnext = 0;
- state->whave = 0;
- }
+ if (inflate_ensure_window(state)) return 1;
/* copy state->wsize or less output bytes into the circular window */
if (copy >= state->wsize) {
static void send_all_trees (deflate_state *s, int lcodes, int dcodes, int blcodes);
static void compress_block (deflate_state *s, const ct_data *ltree, const ct_data *dtree);
static int detect_data_type (deflate_state *s);
-static unsigned bi_reverse (unsigned code, int len);
static void bi_flush (deflate_state *s);
#ifdef GEN_TREES_H
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
-static unsigned bi_reverse(unsigned code, int len) {
+ZLIB_INTERNAL unsigned bi_reverse(unsigned code, int len) {
/* code: the value to invert */
/* len: its bit length */
register unsigned res = 0;