summaryrefslogtreecommitdiff
path: root/inftrees.c
diff options
context:
space:
mode:
Diffstat (limited to 'inftrees.c')
-rw-r--r--inftrees.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/inftrees.c b/inftrees.c
index 11967c8..e4d7bdf 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -1,12 +1,12 @@
1/* inftrees.c -- generate Huffman trees for efficient decoding 1/* inftrees.c -- generate Huffman trees for efficient decoding
2 * Copyright (C) 1995-1996 Mark Adler 2 * Copyright (C) 1995 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#include "zutil.h" 6#include "zutil.h"
7#include "inftrees.h" 7#include "inftrees.h"
8 8
9char inflate_copyright[] = " inflate 1.0 Copyright 1995-1996 Mark Adler "; 9char inflate_copyright[] = " inflate 1.0 Copyright 1995 Mark Adler ";
10/* 10/*
11 If you use the zlib library in a product, an acknowledgment is welcome 11 If you use the zlib library in a product, an acknowledgment is welcome
12 in the documentation of your product. If for some reason you cannot 12 in the documentation of your product. If for some reason you cannot
@@ -38,18 +38,18 @@ local voidpf falloc OF((
38 uInt)); /* size of item */ 38 uInt)); /* size of item */
39 39
40/* Tables for deflate from PKZIP's appnote.txt. */ 40/* Tables for deflate from PKZIP's appnote.txt. */
41local uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ 41local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
42 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 42 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
43 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 43 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
44 /* actually lengths - 2; also see note #13 above about 258 */ 44 /* actually lengths - 2; also see note #13 above about 258 */
45local uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ 45local uInt cplext[] = { /* Extra bits for literal codes 257..285 */
46 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 46 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
47 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */ 47 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */
48local uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ 48local uInt cpdist[] = { /* Copy offsets for distance codes 0..29 */
49 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 49 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
50 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 50 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
51 8193, 12289, 16385, 24577}; 51 8193, 12289, 16385, 24577};
52local uInt cpdext[30] = { /* Extra bits for distance codes */ 52local uInt cpdext[] = { /* Extra bits for distance codes */
53 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 53 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
54 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 54 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
55 12, 12, 13, 13}; 55 12, 12, 13, 13};
@@ -307,11 +307,11 @@ z_stream *z; /* for zfree function */
307 307
308 r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z); 308 r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
309 if (r == Z_DATA_ERROR) 309 if (r == Z_DATA_ERROR)
310 z->msg = (char*)"oversubscribed dynamic bit lengths tree"; 310 z->msg = "oversubscribed dynamic bit lengths tree";
311 else if (r == Z_BUF_ERROR) 311 else if (r == Z_BUF_ERROR)
312 { 312 {
313 inflate_trees_free(*tb, z); 313 inflate_trees_free(*tb, z);
314 z->msg = (char*)"incomplete dynamic bit lengths tree"; 314 z->msg = "incomplete dynamic bit lengths tree";
315 r = Z_DATA_ERROR; 315 r = Z_DATA_ERROR;
316 } 316 }
317 return r; 317 return r;
@@ -334,11 +334,11 @@ z_stream *z; /* for zfree function */
334 if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK) 334 if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK)
335 { 335 {
336 if (r == Z_DATA_ERROR) 336 if (r == Z_DATA_ERROR)
337 z->msg = (char*)"oversubscribed literal/length tree"; 337 z->msg = "oversubscribed literal/length tree";
338 else if (r == Z_BUF_ERROR) 338 else if (r == Z_BUF_ERROR)
339 { 339 {
340 inflate_trees_free(*tl, z); 340 inflate_trees_free(*tl, z);
341 z->msg = (char*)"incomplete literal/length tree"; 341 z->msg = "incomplete literal/length tree";
342 r = Z_DATA_ERROR; 342 r = Z_DATA_ERROR;
343 } 343 }
344 return r; 344 return r;
@@ -348,14 +348,14 @@ z_stream *z; /* for zfree function */
348 if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK) 348 if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK)
349 { 349 {
350 if (r == Z_DATA_ERROR) 350 if (r == Z_DATA_ERROR)
351 z->msg = (char*)"oversubscribed literal/length tree"; 351 z->msg = "oversubscribed literal/length tree";
352 else if (r == Z_BUF_ERROR) { 352 else if (r == Z_BUF_ERROR) {
353#ifdef PKZIP_BUG_WORKAROUND 353#ifdef PKZIP_BUG_WORKAROUND
354 r = Z_OK; 354 r = Z_OK;
355 } 355 }
356#else 356#else
357 inflate_trees_free(*td, z); 357 inflate_trees_free(*td, z);
358 z->msg = (char*)"incomplete literal/length tree"; 358 z->msg = "incomplete literal/length tree";
359 r = Z_DATA_ERROR; 359 r = Z_DATA_ERROR;
360 } 360 }
361 inflate_trees_free(*tl, z); 361 inflate_trees_free(*tl, z);
@@ -385,7 +385,7 @@ uInt s; /* size of item */
385{ 385{
386 Assert(s == sizeof(inflate_huft) && n <= *(intf *)q, 386 Assert(s == sizeof(inflate_huft) && n <= *(intf *)q,
387 "inflate_trees falloc overflow"); 387 "inflate_trees falloc overflow");
388 *(intf *)q -= n+s-s; /* s-s to avoid warning */ 388 *(intf *)q -= n;
389 return (voidpf)(fixed_mem + *(intf *)q); 389 return (voidpf)(fixed_mem + *(intf *)q);
390} 390}
391 391