X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdecompress_common.c;h=c2f76955c17043f2b39dcab98d9fdb7a59e36f7b;hp=4ab9ccbe1c34fdb0519fa7cb0fe72e8e22bfc7ec;hb=8b709192cd2811b83c248fbe61ca4f11ee9de797;hpb=0ecb0529b5fcacc1abafa1f3f02a40c44783ada8 diff --git a/src/decompress_common.c b/src/decompress_common.c index 4ab9ccbe..c2f76955 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; @@ -150,14 +154,6 @@ make_huffman_decode_table(u16 decode_table[const restrict], const unsigned entries_per_xmm = sizeof(__m128i) / sizeof(decode_table[0]); #endif - /* Check parameters if assertions are enabled. */ - wimlib_assert2((uintptr_t)decode_table % DECODE_TABLE_ALIGNMENT == 0); - wimlib_assert2(num_syms <= DECODE_TABLE_MAX_SYMBOLS); - wimlib_assert2(table_bits <= DECODE_TABLE_MAX_TABLE_BITS); - wimlib_assert2(max_codeword_len <= DECODE_TABLE_MAX_CODEWORD_LEN); - for (unsigned sym = 0; sym < num_syms; sym++) - wimlib_assert2(lens[sym] <= max_codeword_len); - /* Count how many symbols have each possible codeword length. * Note that a length of 0 indicates the corresponding symbol is not * used in the code and therefore does not have a codeword. */