Rev 1896 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1896 | Rev 3926 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* infback.c -- inflate using a call-back interface |
1 | /* infback.c -- inflate using a call-back interface |
2 | * Copyright (C) 1995-2009 Mark Adler |
2 | * Copyright (C) 1995-2011 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ |
4 | */ |
Line 5... | Line 5... | ||
5 | 5 | ||
6 | /* |
6 | /* |
Line 40... | Line 40... | ||
40 | if (strm == Z_NULL || window == Z_NULL || |
40 | if (strm == Z_NULL || window == Z_NULL || |
41 | windowBits < 8 || windowBits > 15) |
41 | windowBits < 8 || windowBits > 15) |
42 | return Z_STREAM_ERROR; |
42 | return Z_STREAM_ERROR; |
43 | strm->msg = Z_NULL; /* in case we return an error */ |
43 | strm->msg = Z_NULL; /* in case we return an error */ |
44 | if (strm->zalloc == (alloc_func)0) { |
44 | if (strm->zalloc == (alloc_func)0) { |
- | 45 | #ifdef Z_SOLO |
|
- | 46 | return Z_STREAM_ERROR; |
|
- | 47 | #else |
|
45 | strm->zalloc = zcalloc; |
48 | strm->zalloc = zcalloc; |
46 | strm->opaque = (voidpf)0; |
49 | strm->opaque = (voidpf)0; |
- | 50 | #endif |
|
47 | } |
51 | } |
48 | if (strm->zfree == (free_func)0) strm->zfree = zcfree; |
52 | if (strm->zfree == (free_func)0) |
- | 53 | #ifdef Z_SOLO |
|
- | 54 | return Z_STREAM_ERROR; |
|
- | 55 | #else |
|
- | 56 | strm->zfree = zcfree; |
|
- | 57 | #endif |
|
49 | state = (struct inflate_state FAR *)ZALLOC(strm, 1, |
58 | state = (struct inflate_state FAR *)ZALLOC(strm, 1, |
50 | sizeof(struct inflate_state)); |
59 | sizeof(struct inflate_state)); |
51 | if (state == Z_NULL) return Z_MEM_ERROR; |
60 | if (state == Z_NULL) return Z_MEM_ERROR; |
52 | Tracev((stderr, "inflate: allocated\n")); |
61 | Tracev((stderr, "inflate: allocated\n")); |
53 | strm->state = (struct internal_state FAR *)state; |
62 | strm->state = (struct internal_state FAR *)state; |
Line 244... | Line 253... | ||
244 | void FAR *in_desc; |
253 | void FAR *in_desc; |
245 | out_func out; |
254 | out_func out; |
246 | void FAR *out_desc; |
255 | void FAR *out_desc; |
247 | { |
256 | { |
248 | struct inflate_state FAR *state; |
257 | struct inflate_state FAR *state; |
249 | unsigned char FAR *next; /* next input */ |
258 | z_const unsigned char FAR *next; /* next input */ |
250 | unsigned char FAR *put; /* next output */ |
259 | unsigned char FAR *put; /* next output */ |
251 | unsigned have, left; /* available input and output */ |
260 | unsigned have, left; /* available input and output */ |
252 | unsigned long hold; /* bit buffer */ |
261 | unsigned long hold; /* bit buffer */ |
253 | unsigned bits; /* bits in bit buffer */ |
262 | unsigned bits; /* bits in bit buffer */ |
254 | unsigned copy; /* number of stored or match bytes to copy */ |
263 | unsigned copy; /* number of stored or match bytes to copy */ |
Line 392... | Line 401... | ||
392 | here = state->lencode[BITS(state->lenbits)]; |
401 | here = state->lencode[BITS(state->lenbits)]; |
393 | if ((unsigned)(here.bits) <= bits) break; |
402 | if ((unsigned)(here.bits) <= bits) break; |
394 | PULLBYTE(); |
403 | PULLBYTE(); |
395 | } |
404 | } |
396 | if (here.val < 16) { |
405 | if (here.val < 16) { |
397 | NEEDBITS(here.bits); |
- | |
398 | DROPBITS(here.bits); |
406 | DROPBITS(here.bits); |
399 | state->lens[state->have++] = here.val; |
407 | state->lens[state->have++] = here.val; |
400 | } |
408 | } |
401 | else { |
409 | else { |
402 | if (here.val == 16) { |
410 | if (here.val == 16) { |