]> wimlib.net Git - wimlib/blobdiff - src/decompress_common.c
Fix win32-test-imagex-capture_and_apply.bat and add to CI
[wimlib] / src / decompress_common.c
index fa605f0cc08b21b301fc641a3e43088fd805b6a2..abdf4df49147516bae28de87bdbb1c7de9ab78c4 100644 (file)
@@ -3,21 +3,28 @@
  *
  * Code for decompression shared among multiple compression formats.
  *
- * The following copying information applies to this specific source code file:
+ * Copyright 2022 Eric Biggers
  *
- * Written in 2012-2016 by Eric Biggers <ebiggers3@gmail.com>
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
  *
- * 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").
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
  *
- * 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 <http://creativecommons.org/publicdomain/zero/1.0/>.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #ifdef HAVE_CONFIG_H
  *     The maximum codeword length permitted for this code.  All entries in
  *     'lens' must be less than or equal to this value.
  *
+ * @working_space
+ *     A temporary array that was declared with DECODE_TABLE_WORKING_SPACE().
+ *
  * Returns 0 on success, or -1 if the lengths do not form a valid prefix code.
  */
 int
 make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
                          unsigned table_bits, const u8 lens[],
-                         unsigned max_codeword_len)
+                         unsigned max_codeword_len, u16 working_space[])
 {
-       u16 len_counts[max_codeword_len + 1];
-       u16 offsets[max_codeword_len + 1];
-       u16 sorted_syms[num_syms];
+       u16 * const len_counts = &working_space[0];
+       u16 * const offsets = &working_space[1 * (max_codeword_len + 1)];
+       u16 * const sorted_syms = &working_space[2 * (max_codeword_len + 1)];
        s32 remainder = 1;
        void *entry_ptr = decode_table;
        unsigned codeword_len = 1;