X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdecompress_common.c;h=76fb1278ab0efed9cdd2ca8cffe2bd5ecd10d8b3;hp=49cd5ba0f083afa64248246080830fd93dfbb589;hb=21da2526eff64cdb8e3cb509d34af182d764c701;hpb=226a6dfe2909e054568298196785c944a1b5c4fa diff --git a/src/decompress_common.c b/src/decompress_common.c index 49cd5ba0..76fb1278 100644 --- a/src/decompress_common.c +++ b/src/decompress_common.c @@ -98,9 +98,11 @@ * binary tree. * * @decode_table: - * The array in which to create the decoding table. - * This must be 16-byte aligned and must have a length of at least - * ((2**table_bits) + 2 * num_syms) entries. + * The array in which to create the decoding table. This must be + * 16-byte aligned and must have a length of at least + * ((2**table_bits) + 2 * num_syms) entries. This is permitted to + * alias @lens, since all information from @lens is consumed before +* anything is written to @decode_table. * * @num_syms: * The number of symbols in the alphabet; also, the length of the @@ -115,7 +117,9 @@ * An array of length @num_syms, indexable by symbol, that gives the * length of the codeword, in bits, for that symbol. The length can * be 0, which means that the symbol does not have a codeword - * assigned. + * assigned. This is permitted to alias @decode_table, since all + * information from @lens is consumed before anything is written to + * @decode_table. * * @max_codeword_len: * The longest codeword length allowed in the compression format. @@ -126,10 +130,10 @@ * code. */ int -make_huffman_decode_table(u16 decode_table[const restrict], +make_huffman_decode_table(u16 decode_table[const], const unsigned num_syms, const unsigned table_bits, - const u8 lens[const restrict], + const u8 lens[const], const unsigned max_codeword_len) { const unsigned table_num_entries = 1 << table_bits; @@ -277,7 +281,7 @@ make_huffman_decode_table(u16 decode_table[const restrict], aliased_word_t *p; unsigned n; - BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8); + STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8); v = MAKE_DIRECT_ENTRY(sorted_syms[sym_idx], codeword_len); v |= v << 16; @@ -373,7 +377,7 @@ make_huffman_decode_table(u16 decode_table[const restrict], * of as simply the root of the tree. The * representation of these internal nodes is * simply the index of the left child combined - * with the special bits 0xC000 to distingush + * with the special bits 0xC000 to distinguish * the entry from direct mapping and leaf node * entries. */ do {