comparison zlib/inftrees.c @ 2690:9ef72ee5c0b0

Update vendored zlib to 1.3.1
author Michael Pavone <pavone@retrodev.com>
date Sun, 15 Jun 2025 15:39:33 -0700
parents 00d788dac91a
children
comparison
equal deleted inserted replaced
2689:bd6e33de0972 2690:9ef72ee5c0b0
1 /* inftrees.c -- generate Huffman trees for efficient decoding 1 /* inftrees.c -- generate Huffman trees for efficient decoding
2 * Copyright (C) 1995-2017 Mark Adler 2 * Copyright (C) 1995-2024 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
9 #define MAXBITS 15 9 #define MAXBITS 15
10 10
11 const char inflate_copyright[] = 11 const char inflate_copyright[] =
12 " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; 12 " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
13 /* 13 /*
14 If you use the zlib library in a product, an acknowledgment is welcome 14 If you use the zlib library in a product, an acknowledgment is welcome
15 in the documentation of your product. If for some reason you cannot 15 in the documentation of your product. If for some reason you cannot
16 include such an acknowledgment, I would appreciate that you keep this 16 include such an acknowledgment, I would appreciate that you keep this
17 copyright string in the executable of your product. 17 copyright string in the executable of your product.
27 on return points to the next available entry's address. bits is the 27 on return points to the next available entry's address. bits is the
28 requested root table index bits, and on return it is the actual root 28 requested root table index bits, and on return it is the actual root
29 table index bits. It will differ if the request is greater than the 29 table index bits. It will differ if the request is greater than the
30 longest code or if it is less than the shortest code. 30 longest code or if it is less than the shortest code.
31 */ 31 */
32 int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) 32 int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
33 codetype type; 33 unsigned codes, code FAR * FAR *table,
34 unsigned short FAR *lens; 34 unsigned FAR *bits, unsigned short FAR *work) {
35 unsigned codes;
36 code FAR * FAR *table;
37 unsigned FAR *bits;
38 unsigned short FAR *work;
39 {
40 unsigned len; /* a code's length in bits */ 35 unsigned len; /* a code's length in bits */
41 unsigned sym; /* index of code symbols */ 36 unsigned sym; /* index of code symbols */
42 unsigned min, max; /* minimum and maximum code lengths */ 37 unsigned min, max; /* minimum and maximum code lengths */
43 unsigned root; /* number of index bits for root table */ 38 unsigned root; /* number of index bits for root table */
44 unsigned curr; /* number of index bits for current table */ 39 unsigned curr; /* number of index bits for current table */
60 static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 55 static const unsigned short lbase[31] = { /* Length codes 257..285 base */
61 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 56 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
62 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 57 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
63 static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 58 static const unsigned short lext[31] = { /* Length codes 257..285 extra */
64 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 59 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
65 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; 60 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
66 static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 61 static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
67 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 62 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
68 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 63 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
69 8193, 12289, 16385, 24577, 0, 0}; 64 8193, 12289, 16385, 24577, 0, 0};
70 static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ 65 static const unsigned short dext[32] = { /* Distance codes 0..29 extra */