Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: third_party/zlib/infback.c

Issue 1955383002: Update Zlib to version 1.2.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unzip on win platform Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/zlib/gzwrite.c ('k') | third_party/zlib/inffast.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 */
5 5
6 /* 6 /*
7 This code is largely copied from inflate.c. Normally either infback.o or 7 This code is largely copied from inflate.c. Normally either infback.o or
8 inflate.o would be linked into an application--not both. The interface 8 inflate.o would be linked into an application--not both. The interface
9 with inffast.c is retained so that optimized assembler-coded versions of 9 with inffast.c is retained so that optimized assembler-coded versions of
10 inflate_fast() can be used with either inflate.c or infback.c. 10 inflate_fast() can be used with either inflate.c or infback.c.
11 */ 11 */
12 12
(...skipping 22 matching lines...) Expand all
35 struct inflate_state FAR *state; 35 struct inflate_state FAR *state;
36 36
37 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || 37 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
38 stream_size != (int)(sizeof(z_stream))) 38 stream_size != (int)(sizeof(z_stream)))
39 return Z_VERSION_ERROR; 39 return Z_VERSION_ERROR;
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;
54 state->dmax = 32768U; 63 state->dmax = 32768U;
55 state->wbits = windowBits; 64 state->wbits = windowBits;
56 state->wsize = 1U << windowBits; 65 state->wsize = 1U << windowBits;
57 state->window = window; 66 state->window = window;
58 state->wnext = 0; 67 state->wnext = 0;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 are not correct, i.e. strm is Z_NULL or the state was not initialized. 248 are not correct, i.e. strm is Z_NULL or the state was not initialized.
240 */ 249 */
241 int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) 250 int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
242 z_streamp strm; 251 z_streamp strm;
243 in_func in; 252 in_func in;
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 */
255 unsigned char FAR *from; /* where to copy match bytes from */ 264 unsigned char FAR *from; /* where to copy match bytes from */
256 code here; /* current decoding table entry */ 265 code here; /* current decoding table entry */
257 code last; /* parent table entry */ 266 code last; /* parent table entry */
258 unsigned len; /* length to copy for repeats, bits to drop */ 267 unsigned len; /* length to copy for repeats, bits to drop */
259 int ret; /* return code */ 268 int ret; /* return code */
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 396
388 /* get length and distance code code lengths */ 397 /* get length and distance code code lengths */
389 state->have = 0; 398 state->have = 0;
390 while (state->have < state->nlen + state->ndist) { 399 while (state->have < state->nlen + state->ndist) {
391 for (;;) { 400 for (;;) {
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) {
403 NEEDBITS(here.bits + 2); 411 NEEDBITS(here.bits + 2);
404 DROPBITS(here.bits); 412 DROPBITS(here.bits);
405 if (state->have == 0) { 413 if (state->have == 0) {
406 strm->msg = (char *)"invalid bit length repeat"; 414 strm->msg = (char *)"invalid bit length repeat";
407 state->mode = BAD; 415 state->mode = BAD;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 int ZEXPORT inflateBackEnd(strm) 631 int ZEXPORT inflateBackEnd(strm)
624 z_streamp strm; 632 z_streamp strm;
625 { 633 {
626 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) 634 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
627 return Z_STREAM_ERROR; 635 return Z_STREAM_ERROR;
628 ZFREE(strm, strm->state); 636 ZFREE(strm, strm->state);
629 strm->state = Z_NULL; 637 strm->state = Z_NULL;
630 Tracev((stderr, "inflate: end\n")); 638 Tracev((stderr, "inflate: end\n"));
631 return Z_OK; 639 return Z_OK;
632 } 640 }
OLDNEW
« no previous file with comments | « third_party/zlib/gzwrite.c ('k') | third_party/zlib/inffast.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698