mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
9fe0a2fa8d
usable for unix builds": zlib 1.2.1 imported BitKeeper/deleted/.del-Make_vms.com~95dd9cc7505c3153: Delete: zlib/Make_vms.com BitKeeper/deleted/.del-Makefile.riscos~f85c6493d3e51733: Delete: zlib/Makefile.riscos BitKeeper/deleted/.del-Makefile.pup~b0e9ed99224cc5f4: Delete: zlib/amiga/Makefile.pup BitKeeper/deleted/.del-Makefile.sas~be103e936c85b66a: Delete: zlib/amiga/Makefile.sas BitKeeper/deleted/.del-README.contrib~2924ba28ef1f9fab: Delete: zlib/contrib/README.contrib BitKeeper/deleted/.del-gvmat32.asm~edf721a2de30e964: Delete: zlib/contrib/asm386/gvmat32.asm BitKeeper/deleted/.del-visual-basic.txt~859fcbcb668ffbb3: Delete: zlib/contrib/visual-basic.txt BitKeeper/deleted/.del-gvmat32c.c~2e97d7d65dd59113: Delete: zlib/contrib/asm386/gvmat32c.c BitKeeper/deleted/.del-mkgvmt32.bat~5a92cf0febe3dc81: Delete: zlib/contrib/asm386/mkgvmt32.bat BitKeeper/deleted/.del-zlibvc.def~67961fa7815b9267: Delete: zlib/contrib/asm386/zlibvc.def BitKeeper/deleted/.del-zlibvc.dsp~a3323c77bcd12995: Delete: zlib/contrib/asm386/zlibvc.dsp BitKeeper/deleted/.del-match.s~51b8fef5136642ed: Delete: zlib/contrib/asm586/match.s BitKeeper/deleted/.del-readme.586~cb1bb7136b0803bb: Delete: zlib/contrib/asm586/readme.586 BitKeeper/deleted/.del-zlibvc.dsw~e3dca9d8f342e64e: Delete: zlib/contrib/asm386/zlibvc.dsw BitKeeper/deleted/.del-match.s~e4bbe1fa486d1c6c: Delete: zlib/contrib/asm686/match.s BitKeeper/deleted/.del-readme.686~98a220c13809fce5: Delete: zlib/contrib/asm686/readme.686 BitKeeper/deleted/.del-zlib.mak~70f7c5f6947fd807: Delete: zlib/contrib/delphi/zlib.mak BitKeeper/deleted/.del-d_zlib.bpr~cefb1beee520d6e8: Delete: zlib/contrib/delphi2/d_zlib.bpr BitKeeper/deleted/.del-d_zlib.cpp~62dff1931881afa6: Delete: zlib/contrib/delphi2/d_zlib.cpp BitKeeper/deleted/.del-zlibdef.pas~780244c8d12b6c53: Delete: zlib/contrib/delphi/zlibdef.pas BitKeeper/deleted/.del-readme.txt~8222e54ca00f2729: Delete: zlib/contrib/delphi2/readme.txt BitKeeper/deleted/.del-zlib.bpg~fbd9308275ad8e3: Delete: zlib/contrib/delphi2/zlib.bpg BitKeeper/deleted/.del-zlib.bpr~fe8bf5d1c4a2ce5a: Delete: zlib/contrib/delphi2/zlib.bpr BitKeeper/deleted/.del-zlib.cpp~bb0c3df062410f5c: Delete: zlib/contrib/delphi2/zlib.cpp BitKeeper/deleted/.del-zlib.pas~1d5285e2449b50a3: Delete: zlib/contrib/delphi2/zlib.pas BitKeeper/deleted/.del-zlib32.bpr~c2a9f0aa47a1d9ad: Delete: zlib/contrib/delphi2/zlib32.bpr BitKeeper/deleted/.del-test.cpp~4480297b204dc360: Delete: zlib/contrib/iostream/test.cpp BitKeeper/deleted/.del-zfstream.cpp~943ecbd558e86dde: Delete: zlib/contrib/iostream/zfstream.cpp BitKeeper/deleted/.del-zlib32.cpp~bbb4a200d2fe6497: Delete: zlib/contrib/delphi2/zlib32.cpp BitKeeper/deleted/.del-ChangeLogUnzip~a3ae0ba899cadd: Delete: zlib/contrib/minizip/ChangeLogUnzip BitKeeper/deleted/.del-zfstream.h~71ee057bdc6366ac: Delete: zlib/contrib/iostream/zfstream.h BitKeeper/deleted/.del-zstream.h~a6f6be5634962c81: Delete: zlib/contrib/iostream2/zstream.h BitKeeper/deleted/.del-zstream_test.cpp~e471b51e7fb553ec: Delete: zlib/contrib/iostream2/zstream_test.cpp BitKeeper/deleted/.del-miniunz.c~9da181975b3a48: Delete: zlib/contrib/minizip/miniunz.c BitKeeper/deleted/.del-minizip.c~4a49a0addb97272b: Delete: zlib/contrib/minizip/minizip.c BitKeeper/deleted/.del-readme.txt~174eb00680149f6b: Delete: zlib/contrib/minizip/readme.txt BitKeeper/deleted/.del-unzip.c~662c5ba4edbb3a19: Delete: zlib/contrib/minizip/unzip.c BitKeeper/deleted/.del-unzip.def~8a0ad6f745ee5cd4: Delete: zlib/contrib/minizip/unzip.def BitKeeper/deleted/.del-unzip.h~d5e800088a368c32: Delete: zlib/contrib/minizip/unzip.h BitKeeper/deleted/.del-zip.c~9750c19a123f3057: Delete: zlib/contrib/minizip/zip.c BitKeeper/deleted/.del-zip.def~4ffe888e9fd7b5aa: Delete: zlib/contrib/minizip/zip.def BitKeeper/deleted/.del-zip.h~4c72b8fcc492f055: Delete: zlib/contrib/minizip/zip.h BitKeeper/deleted/.del-zlibvc.def~dd272b3ed71647ba: Delete: zlib/contrib/minizip/zlibvc.def BitKeeper/deleted/.del-zlibvc.dsp~ad83fb048811e2d2: Delete: zlib/contrib/minizip/zlibvc.dsp BitKeeper/deleted/.del-zlibvc.dsw~c66b33a2d52f37c5: Delete: zlib/contrib/minizip/zlibvc.dsw BitKeeper/deleted/.del-makefile.w32~6507530fa1b017c: Delete: zlib/contrib/untgz/makefile.w32 BitKeeper/deleted/.del-untgz.c~4e8f1a3a2c145373: Delete: zlib/contrib/untgz/untgz.c BitKeeper/deleted/.del-Makefile.os2~8ab058477b24d1ff: Delete: zlib/os2/Makefile.os2 BitKeeper/deleted/.del-zlib.def~385b56ed82784ff3: Delete: zlib/os2/zlib.def BitKeeper/deleted/.del-Makefile.b32~10ffaac6cc41847a: Delete: zlib/msdos/Makefile.b32 BitKeeper/deleted/.del-Makefile.bor~121b2bc837b6367: Delete: zlib/msdos/Makefile.bor BitKeeper/deleted/.del-Makefile.dj2~a069623cad6ce7f4: Delete: zlib/msdos/Makefile.dj2 BitKeeper/deleted/.del-Makefile.emx~11a9e6c8a719ba60: Delete: zlib/msdos/Makefile.emx BitKeeper/deleted/.del-Makefile.msc~ba5ad7709ff22aab: Delete: zlib/msdos/Makefile.msc BitKeeper/deleted/.del-Makefile.tc~d1398368648e8836: Delete: zlib/msdos/Makefile.tc BitKeeper/deleted/.del-Makefile.w32~921a473e873d94d1: Delete: zlib/msdos/Makefile.w32 BitKeeper/deleted/.del-Makefile.wat~b2b51cbc2c2bc2f4: Delete: zlib/msdos/Makefile.wat BitKeeper/deleted/.del-zlib.def~189fba701e5e4b9c: Delete: zlib/msdos/zlib.def BitKeeper/deleted/.del-zlib.rc~e5ce22c7c915ec00: Delete: zlib/msdos/zlib.rc BitKeeper/deleted/.del-Makefile.emx~b5fa0633cbe6fe01: Delete: zlib/nt/Makefile.emx BitKeeper/deleted/.del-Makefile.gcc~7fcd3dd326341fa0: Delete: zlib/nt/Makefile.gcc BitKeeper/deleted/.del-Makefile.nt~9910c98f5da056de: Delete: zlib/nt/Makefile.nt BitKeeper/deleted/.del-zlib.dnt~8160c636eb3eeed7: Delete: zlib/nt/zlib.dnt BitKeeper/deleted/.del-zlib.dsp~a8abac2fb721276e: Delete: zlib/zlib.dsp BitKeeper/deleted/.del-zlib.html~2e74efd497dcd4d0: Delete: zlib/zlib.html BitKeeper/deleted/.del-minigzip.c~1f21a5863f457cb0: Delete: zlib/minigzip.c BitKeeper/deleted/.del-example.c~5ea43c929ccd2a4f: Delete: zlib/example.c BitKeeper/deleted/.del-descrip.mms~51cd5d1792d76b9c: Delete: zlib/descrip.mms BitKeeper/deleted/.del-infblock.h~7d4f40c3a1d4cdf8: Delete: zlib/infblock.h BitKeeper/deleted/.del-infblock.c~3c866934e0f44c43: Delete: zlib/infblock.c BitKeeper/deleted/.del-infutil.c~43d2340436244b52: Delete: zlib/infutil.c BitKeeper/deleted/.del-infutil.h~a6bd0dcbbdc187ac: Delete: zlib/infutil.h BitKeeper/deleted/.del-infcodes.h~c9f64a612c2cc56a: Delete: zlib/infcodes.h BitKeeper/deleted/.del-infcodes.c~7ed73df8a54d6d55: Delete: zlib/infcodes.c BitKeeper/deleted/.del-maketree.c~846b8b96ac6872d8: Delete: zlib/maketree.c VC++Files/zlib/zlib.dsp: Modified to suit zlib upgrade. mysys/my_crc32.c: Modified to suit zlib upgrade. zlib/ChangeLog: zlib 1.2.1 imported zlib/FAQ: zlib 1.2.1 imported zlib/INDEX: zlib 1.2.1 imported zlib/README: zlib 1.2.1 imported zlib/adler32.c: zlib 1.2.1 imported zlib/algorithm.txt: zlib 1.2.1 imported zlib/compress.c: zlib 1.2.1 imported zlib/crc32.c: zlib 1.2.1 imported zlib/deflate.c: zlib 1.2.1 imported zlib/deflate.h: zlib 1.2.1 imported zlib/gzio.c: zlib 1.2.1 imported zlib/inffast.c: zlib 1.2.1 imported zlib/inffast.h: zlib 1.2.1 imported zlib/inffixed.h: zlib 1.2.1 imported zlib/inflate.c: zlib 1.2.1 imported zlib/inftrees.c: zlib 1.2.1 imported zlib/inftrees.h: zlib 1.2.1 imported zlib/trees.c: zlib 1.2.1 imported zlib/uncompr.c: zlib 1.2.1 imported zlib/zconf.h: zlib 1.2.1 imported zlib/zlib.3: zlib 1.2.1 imported zlib/zlib.h: zlib 1.2.1 imported zlib/zutil.c: zlib 1.2.1 imported zlib/zutil.h: zlib 1.2.1 imported
321 lines
13 KiB
C
321 lines
13 KiB
C
/* inftrees.c -- generate Huffman trees for efficient decoding
|
|
* Copyright (C) 1995-2003 Mark Adler
|
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
*/
|
|
|
|
#include "zutil.h"
|
|
#include "inftrees.h"
|
|
|
|
#define MAXBITS 15
|
|
|
|
const char inflate_copyright[] =
|
|
" inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
|
|
/*
|
|
If you use the zlib library in a product, an acknowledgment is welcome
|
|
in the documentation of your product. If for some reason you cannot
|
|
include such an acknowledgment, I would appreciate that you keep this
|
|
copyright string in the executable of your product.
|
|
*/
|
|
|
|
/*
|
|
Build a set of tables to decode the provided canonical Huffman code.
|
|
The code lengths are lens[0..codes-1]. The result starts at *table,
|
|
whose indices are 0..2^bits-1. work is a writable array of at least
|
|
lens shorts, which is used as a work area. type is the type of code
|
|
to be generated, CODES, LENS, or DISTS. On return, zero is success,
|
|
-1 is an invalid code, and +1 means that ENOUGH isn't enough. table
|
|
on return points to the next available entry's address. bits is the
|
|
requested root table index bits, and on return it is the actual root
|
|
table index bits. It will differ if the request is greater than the
|
|
longest code or if it is less than the shortest code.
|
|
*/
|
|
int inflate_table(type, lens, codes, table, bits, work)
|
|
codetype type;
|
|
unsigned short FAR *lens;
|
|
unsigned codes;
|
|
code FAR * FAR *table;
|
|
unsigned FAR *bits;
|
|
unsigned short FAR *work;
|
|
{
|
|
unsigned len; /* a code's length in bits */
|
|
unsigned sym; /* index of code symbols */
|
|
unsigned min, max; /* minimum and maximum code lengths */
|
|
unsigned root; /* number of index bits for root table */
|
|
unsigned curr; /* number of index bits for current table */
|
|
unsigned drop; /* code bits to drop for sub-table */
|
|
int left; /* number of prefix codes available */
|
|
unsigned used; /* code entries in table used */
|
|
unsigned huff; /* Huffman code */
|
|
unsigned incr; /* for incrementing code, index */
|
|
unsigned fill; /* index for replicating entries */
|
|
unsigned low; /* low bits for current root entry */
|
|
unsigned mask; /* mask for low root bits */
|
|
code this; /* table entry for duplication */
|
|
code FAR *next; /* next available space in table */
|
|
const unsigned short FAR *base; /* base value table to use */
|
|
const unsigned short FAR *extra; /* extra bits table to use */
|
|
int end; /* use base and extra for symbol > end */
|
|
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
|
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
|
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
|
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
|
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
|
8193, 12289, 16385, 24577, 0, 0};
|
|
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
|
|
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
|
|
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
|
28, 28, 29, 29, 64, 64};
|
|
|
|
/*
|
|
Process a set of code lengths to create a canonical Huffman code. The
|
|
code lengths are lens[0..codes-1]. Each length corresponds to the
|
|
symbols 0..codes-1. The Huffman code is generated by first sorting the
|
|
symbols by length from short to long, and retaining the symbol order
|
|
for codes with equal lengths. Then the code starts with all zero bits
|
|
for the first code of the shortest length, and the codes are integer
|
|
increments for the same length, and zeros are appended as the length
|
|
increases. For the deflate format, these bits are stored backwards
|
|
from their more natural integer increment ordering, and so when the
|
|
decoding tables are built in the large loop below, the integer codes
|
|
are incremented backwards.
|
|
|
|
This routine assumes, but does not check, that all of the entries in
|
|
lens[] are in the range 0..MAXBITS. The caller must assure this.
|
|
1..MAXBITS is interpreted as that code length. zero means that that
|
|
symbol does not occur in this code.
|
|
|
|
The codes are sorted by computing a count of codes for each length,
|
|
creating from that a table of starting indices for each length in the
|
|
sorted table, and then entering the symbols in order in the sorted
|
|
table. The sorted table is work[], with that space being provided by
|
|
the caller.
|
|
|
|
The length counts are used for other purposes as well, i.e. finding
|
|
the minimum and maximum length codes, determining if there are any
|
|
codes at all, checking for a valid set of lengths, and looking ahead
|
|
at length counts to determine sub-table sizes when building the
|
|
decoding tables.
|
|
*/
|
|
|
|
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
|
|
for (len = 0; len <= MAXBITS; len++)
|
|
count[len] = 0;
|
|
for (sym = 0; sym < codes; sym++)
|
|
count[lens[sym]]++;
|
|
|
|
/* bound code lengths, force root to be within code lengths */
|
|
root = *bits;
|
|
for (max = MAXBITS; max >= 1; max--)
|
|
if (count[max] != 0) break;
|
|
if (root > max) root = max;
|
|
if (max == 0) return -1; /* no codes! */
|
|
for (min = 1; min <= MAXBITS; min++)
|
|
if (count[min] != 0) break;
|
|
if (root < min) root = min;
|
|
|
|
/* check for an over-subscribed or incomplete set of lengths */
|
|
left = 1;
|
|
for (len = 1; len <= MAXBITS; len++) {
|
|
left <<= 1;
|
|
left -= count[len];
|
|
if (left < 0) return -1; /* over-subscribed */
|
|
}
|
|
if (left > 0 && (type == CODES || (codes - count[0] != 1)))
|
|
return -1; /* incomplete set */
|
|
|
|
/* generate offsets into symbol table for each length for sorting */
|
|
offs[1] = 0;
|
|
for (len = 1; len < MAXBITS; len++)
|
|
offs[len + 1] = offs[len] + count[len];
|
|
|
|
/* sort symbols by length, by symbol order within each length */
|
|
for (sym = 0; sym < codes; sym++)
|
|
if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
|
|
|
|
/*
|
|
Create and fill in decoding tables. In this loop, the table being
|
|
filled is at next and has curr index bits. The code being used is huff
|
|
with length len. That code is converted to an index by dropping drop
|
|
bits off of the bottom. For codes where len is less than drop + curr,
|
|
those top drop + curr - len bits are incremented through all values to
|
|
fill the table with replicated entries.
|
|
|
|
root is the number of index bits for the root table. When len exceeds
|
|
root, sub-tables are created pointed to by the root entry with an index
|
|
of the low root bits of huff. This is saved in low to check for when a
|
|
new sub-table should be started. drop is zero when the root table is
|
|
being filled, and drop is root when sub-tables are being filled.
|
|
|
|
When a new sub-table is needed, it is necessary to look ahead in the
|
|
code lengths to determine what size sub-table is needed. The length
|
|
counts are used for this, and so count[] is decremented as codes are
|
|
entered in the tables.
|
|
|
|
used keeps track of how many table entries have been allocated from the
|
|
provided *table space. It is checked when a LENS table is being made
|
|
against the space in *table, ENOUGH, minus the maximum space needed by
|
|
the worst case distance code, MAXD. This should never happen, but the
|
|
sufficiency of ENOUGH has not been proven exhaustively, hence the check.
|
|
This assumes that when type == LENS, bits == 9.
|
|
|
|
sym increments through all symbols, and the loop terminates when
|
|
all codes of length max, i.e. all codes, have been processed. This
|
|
routine permits incomplete codes, so another loop after this one fills
|
|
in the rest of the decoding tables with invalid code markers.
|
|
*/
|
|
|
|
/* set up for code type */
|
|
switch (type) {
|
|
case CODES:
|
|
base = extra = work; /* dummy value--not used */
|
|
end = 19;
|
|
break;
|
|
case LENS:
|
|
base = lbase;
|
|
base -= 257;
|
|
extra = lext;
|
|
extra -= 257;
|
|
end = 256;
|
|
break;
|
|
default: /* DISTS */
|
|
base = dbase;
|
|
extra = dext;
|
|
end = -1;
|
|
}
|
|
|
|
/* initialize state for loop */
|
|
huff = 0; /* starting code */
|
|
sym = 0; /* starting code symbol */
|
|
len = min; /* starting code length */
|
|
next = *table; /* current table to fill in */
|
|
curr = root; /* current table index bits */
|
|
drop = 0; /* current bits to drop from code for index */
|
|
low = (unsigned)(-1); /* trigger new sub-table when len > root */
|
|
used = 1U << root; /* use root table entries */
|
|
mask = used - 1; /* mask for comparing low */
|
|
|
|
/* check available table space */
|
|
if (type == LENS && used >= ENOUGH - MAXD)
|
|
return 1;
|
|
|
|
/* process all codes and make table entries */
|
|
for (;;) {
|
|
/* create table entry */
|
|
this.bits = (unsigned char)(len - drop);
|
|
if ((int)(work[sym]) < end) {
|
|
this.op = (unsigned char)0;
|
|
this.val = work[sym];
|
|
}
|
|
else if ((int)(work[sym]) > end) {
|
|
this.op = (unsigned char)(extra[work[sym]]);
|
|
this.val = base[work[sym]];
|
|
}
|
|
else {
|
|
this.op = (unsigned char)(32 + 64); /* end of block */
|
|
this.val = 0;
|
|
}
|
|
|
|
/* replicate for those indices with low len bits equal to huff */
|
|
incr = 1U << (len - drop);
|
|
fill = 1U << curr;
|
|
do {
|
|
fill -= incr;
|
|
next[(huff >> drop) + fill] = this;
|
|
} while (fill != 0);
|
|
|
|
/* backwards increment the len-bit code huff */
|
|
incr = 1U << (len - 1);
|
|
while (huff & incr)
|
|
incr >>= 1;
|
|
if (incr != 0) {
|
|
huff &= incr - 1;
|
|
huff += incr;
|
|
}
|
|
else
|
|
huff = 0;
|
|
|
|
/* go to next symbol, update count, len */
|
|
sym++;
|
|
if (--(count[len]) == 0) {
|
|
if (len == max) break;
|
|
len = lens[work[sym]];
|
|
}
|
|
|
|
/* create new sub-table if needed */
|
|
if (len > root && (huff & mask) != low) {
|
|
/* if first time, transition to sub-tables */
|
|
if (drop == 0)
|
|
drop = root;
|
|
|
|
/* increment past last table */
|
|
next += 1U << curr;
|
|
|
|
/* determine length of next table */
|
|
curr = len - drop;
|
|
left = (int)(1 << curr);
|
|
while (curr + drop < max) {
|
|
left -= count[curr + drop];
|
|
if (left <= 0) break;
|
|
curr++;
|
|
left <<= 1;
|
|
}
|
|
|
|
/* check for enough space */
|
|
used += 1U << curr;
|
|
if (type == LENS && used >= ENOUGH - MAXD)
|
|
return 1;
|
|
|
|
/* point entry in root table to sub-table */
|
|
low = huff & mask;
|
|
(*table)[low].op = (unsigned char)curr;
|
|
(*table)[low].bits = (unsigned char)root;
|
|
(*table)[low].val = (unsigned short)(next - *table);
|
|
}
|
|
}
|
|
|
|
/*
|
|
Fill in rest of table for incomplete codes. This loop is similar to the
|
|
loop above in incrementing huff for table indices. It is assumed that
|
|
len is equal to curr + drop, so there is no loop needed to increment
|
|
through high index bits. When the current sub-table is filled, the loop
|
|
drops back to the root table to fill in any remaining entries there.
|
|
*/
|
|
this.op = (unsigned char)64; /* invalid code marker */
|
|
this.bits = (unsigned char)(len - drop);
|
|
this.val = (unsigned short)0;
|
|
while (huff != 0) {
|
|
/* when done with sub-table, drop back to root table */
|
|
if (drop != 0 && (huff & mask) != low) {
|
|
drop = 0;
|
|
len = root;
|
|
next = *table;
|
|
curr = root;
|
|
this.bits = (unsigned char)len;
|
|
}
|
|
|
|
/* put invalid code marker in table */
|
|
next[huff >> drop] = this;
|
|
|
|
/* backwards increment the len-bit code huff */
|
|
incr = 1U << (len - 1);
|
|
while (huff & incr)
|
|
incr >>= 1;
|
|
if (incr != 0) {
|
|
huff &= incr - 1;
|
|
huff += incr;
|
|
}
|
|
else
|
|
huff = 0;
|
|
}
|
|
|
|
/* set return parameters */
|
|
*table += used;
|
|
*bits = root;
|
|
return 0;
|
|
}
|