X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fdecompress.c;h=f149b48c7bcf06f9172d48d9e7da0568b26f80fb;hb=768d53aa2bde3b39dfa85fe0dd940d67ae97d5ef;hp=6ca0f1616c767bb4b4b8fcb7abf343478b4b4c7a;hpb=a3bb2e86f2640f5d593d00250a627d3dcc9747a2;p=wimlib diff --git a/src/decompress.c b/src/decompress.c index 6ca0f161..f149b48c 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -23,7 +23,13 @@ * along with wimlib; if not, see http://www.gnu.org/licenses/. */ -#include "decompress.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "wimlib/decompress.h" +#include "wimlib/util.h" + #include /* @@ -90,8 +96,8 @@ * pointers by the fact that values less than @num_syms must be symbol values. */ int -make_huffman_decode_table(u16 decode_table[], unsigned num_syms, - unsigned table_bits, const u8 lens[], +make_huffman_decode_table(u16 * restrict decode_table, unsigned num_syms, + unsigned table_bits, const u8 * restrict lens, unsigned max_codeword_len) { unsigned len_counts[max_codeword_len + 1]; @@ -165,41 +171,13 @@ make_huffman_decode_table(u16 decode_table[], unsigned num_syms, break; unsigned num_entries = 1 << (table_bits - codeword_len); - const unsigned entries_per_long = sizeof(unsigned long) / - sizeof(decode_table[0]); - if (num_entries >= entries_per_long) { - /* Fill in the Huffman decode table entries one unsigned - * long at a time. On 32-bit systems this is 2 entries - * per store, while on 64-bit systems this is 4 entries - * per store. */ - wimlib_assert2(decode_table_pos % entries_per_long == 0); - BUILD_BUG_ON(sizeof(unsigned long) != 4 && - sizeof(unsigned long) != 8); - - unsigned long *p = (unsigned long *)&decode_table[decode_table_pos]; - unsigned n = num_entries / entries_per_long; - unsigned long v = sym; - if (sizeof(unsigned long) >= 4) - v |= v << 16; - if (sizeof(unsigned long) >= 8) { - /* This may produce a compiler warning if an - * unsigned long is 32 bits, but this won't be - * executed unless an unsigned long is at least - * 64 bits anyway. */ - v |= v << 32; - } - do { - *p++ = v; - } while (--n); - decode_table_pos += num_entries; - } else { - /* Fill in the Huffman decode table entries one 16-bit - * integer at a time. */ - do { - decode_table[decode_table_pos++] = sym; - } while (--num_entries); - } + /* Fill in the Huffman decode table entries one 16-bit + * integer at a time. */ + do { + decode_table[decode_table_pos++] = sym; + } while (--num_entries); + wimlib_assert2(decode_table_pos <= table_num_entries); if (++i == num_used_syms) { wimlib_assert2(decode_table_pos == table_num_entries);