X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcompress_common.c;h=c6d1133f901c909181a170f9bab0b1870358b7ab;hb=ba30eb632ad9bd2e008267a10eed3e20e4c94ed2;hp=130bfc1167f9eaa30bf9e55fee05cf41c76226a4;hpb=4dae2eef895b95d1c2bc1bf5fc17413af8cc7952;p=wimlib diff --git a/src/compress_common.c b/src/compress_common.c index 130bfc11..c6d1133f 100644 --- a/src/compress_common.c +++ b/src/compress_common.c @@ -3,23 +3,32 @@ * * Code for compression shared among multiple compression formats. * - * Author: Eric Biggers - * Year: 2012 - 2014 + * The following copying information applies to this specific source code file: * - * The author dedicates this file to the public domain. - * You can do whatever you want with this file. + * Written in 2012-2014 by Eric Biggers + * + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide via the Creative Commons Zero 1.0 Universal Public Domain + * Dedication (the "CC0"). + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the CC0 for more details. + * + * You should have received a copy of the CC0 along with this software; if not + * see . */ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "wimlib/assert.h" +#include + #include "wimlib/compress_common.h" #include "wimlib/util.h" -#include - /* Given the binary tree node A[subtree_idx] whose children already * satisfy the maxheap property, swap the node with its greater child * until it is greater than both its children, so that the maxheap @@ -126,7 +135,7 @@ sort_symbols(unsigned num_syms, const u32 freqs[restrict], * Tests were done with building the codes for LZX. Results may * vary for different compression algorithms...! */ - num_counters = (DIV_ROUND_UP(num_syms, 4) + 3) & ~3; + num_counters = ALIGN(DIV_ROUND_UP(num_syms, 4), 4); unsigned counters[num_counters]; @@ -581,12 +590,6 @@ make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, u32 *A = codewords; unsigned num_used_syms; - /* Assumptions */ - wimlib_assert2(num_syms >= 2); - wimlib_assert2(num_syms <= (1 << NUM_SYMBOL_BITS)); - wimlib_assert2((1ULL << max_codeword_len) >= num_syms); - wimlib_assert2(max_codeword_len <= 32); - /* We begin by sorting the symbols primarily by frequency and * secondarily by symbol value. As an optimization, the array * used for this purpose ('A') shares storage with the space in