multi_compress 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -3
- data/GET_STARTED.md +3 -3
- data/README.md +75 -66
- data/THIRD_PARTY_NOTICES.md +24 -0
- data/ext/multi_compress/brotli_dec_static_init.c +3 -0
- data/ext/multi_compress/brotli_enc_static_init.c +3 -0
- data/ext/multi_compress/extconf.rb +79 -3
- data/ext/multi_compress/multi_compress.c +199 -120
- data/ext/multi_compress/vendor/.vendored +2 -2
- data/ext/multi_compress/vendor/brotli/LICENSE +19 -0
- data/ext/multi_compress/vendor/brotli/c/common/constants.c +7 -7
- data/ext/multi_compress/vendor/brotli/c/common/constants.h +2 -5
- data/ext/multi_compress/vendor/brotli/c/common/context.c +2 -2
- data/ext/multi_compress/vendor/brotli/c/common/context.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +4 -5856
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary_inc.h +5847 -0
- data/ext/multi_compress/vendor/brotli/c/common/platform.c +0 -4
- data/ext/multi_compress/vendor/brotli/c/common/platform.h +182 -43
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +3 -7
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/common/static_init.h +56 -0
- data/ext/multi_compress/vendor/brotli/c/common/transform.c +6 -4
- data/ext/multi_compress/vendor/brotli/c/common/transform.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/version.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +2 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/dec/decode.c +128 -39
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +2 -5
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.c +67 -0
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +18 -708
- data/ext/multi_compress/vendor/brotli/c/dec/prefix_inc.h +707 -0
- data/ext/multi_compress/vendor/brotli/c/dec/state.c +18 -15
- data/ext/multi_compress/vendor/brotli/c/dec/state.h +2 -6
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.c +53 -0
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +32 -8
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +15 -15
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +28 -4
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +8 -40
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +9 -12
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +0 -3
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +14 -8
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +10 -9
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +0 -6
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/command.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/command.h +8 -10
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +3 -5
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +3 -13
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +5 -15
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +127 -1830
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +23 -3
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash_inc.h +1829 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encode.c +77 -52
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +9 -7
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +3 -6
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +18 -12
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +2 -3
- data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/hash.h +38 -31
- data/ext/multi_compress/vendor/brotli/c/enc/hash_base.h +38 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +11 -1
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +24 -7
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_simd_inc.h +304 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +30 -11
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +4 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_simd_inc.h +278 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +1 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +4 -6
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/matching_tag_mask.h +69 -0
- data/ext/multi_compress/vendor/brotli/c/enc/memory.c +0 -5
- data/ext/multi_compress/vendor/brotli/c/enc/memory.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +7 -9
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +4 -4
- data/ext/multi_compress/vendor/brotli/c/enc/params.h +0 -1
- data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/quality.h +17 -10
- data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/state.h +2 -2
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +5 -11
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +1 -3
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.c +224 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +20 -5837
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut_inc.h +5830 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.c +59 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init_lazy.cc +26 -0
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +5 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +4 -7
- data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +2 -2
- data/ext/multi_compress/vendor/lz4/LICENSE +12 -0
- data/ext/multi_compress/vendor/zstd/COPYING +339 -0
- data/ext/multi_compress/vendor/zstd/LICENSE +30 -0
- data/ext/multi_compress/vendor/zstd/lib/Makefile +67 -35
- data/ext/multi_compress/vendor/zstd/lib/README.md +33 -2
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +205 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +84 -108
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +170 -41
- data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +37 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.c +7 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.h +21 -21
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +12 -40
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +10 -2
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +46 -47
- data/ext/multi_compress/vendor/zstd/lib/common/fse.h +8 -100
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +28 -116
- data/ext/multi_compress/vendor/zstd/lib/common/huf.h +79 -166
- data/ext/multi_compress/vendor/zstd/lib/common/mem.h +46 -66
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +27 -11
- data/ext/multi_compress/vendor/zstd/lib/common/pool.h +8 -11
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +45 -11
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +74 -14
- data/ext/multi_compress/vendor/zstd/lib/common/threading.h +5 -18
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +5 -11
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +2411 -1003
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +1 -36
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +13 -1
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +13 -182
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +6 -13
- data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +15 -131
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +11 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +8 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +283 -189
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +2419 -903
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +423 -245
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +116 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +16 -8
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +10 -10
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +8 -7
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +254 -139
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +184 -95
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +163 -81
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +18 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +507 -197
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +7 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +579 -484
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +133 -65
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +61 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +7 -15
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +352 -218
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +37 -21
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +239 -175
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +5 -16
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +543 -488
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +78 -61
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +295 -115
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +430 -293
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +7 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +11 -7
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +95 -46
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +3 -9
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +0 -10
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +25 -97
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +1 -1
- data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +38 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +19 -50
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +27 -80
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +28 -83
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +25 -74
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +31 -76
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +44 -88
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +33 -84
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +65 -33
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +5 -5
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +13 -3
- data/ext/multi_compress/vendor/zstd/lib/zdict.h +65 -36
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +890 -267
- data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +28 -16
- data/lib/multi_compress/version.rb +1 -1
- data/lib/multi_compress.rb +80 -41
- metadata +29 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) Yann Collet,
|
|
2
|
+
* Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#include <string.h> /* memcpy */
|
|
17
17
|
|
|
18
18
|
#include "zstd_v04.h"
|
|
19
|
+
#include "../common/compiler.h"
|
|
19
20
|
#include "../common/error_private.h"
|
|
20
21
|
|
|
21
22
|
|
|
@@ -37,15 +38,6 @@ extern "C" {
|
|
|
37
38
|
# include <stdlib.h> /* _byteswap_ulong */
|
|
38
39
|
# include <intrin.h> /* _byteswap_* */
|
|
39
40
|
#endif
|
|
40
|
-
#if defined(__GNUC__)
|
|
41
|
-
# define MEM_STATIC static __attribute__((unused))
|
|
42
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
|
43
|
-
# define MEM_STATIC static inline
|
|
44
|
-
#elif defined(_MSC_VER)
|
|
45
|
-
# define MEM_STATIC static __inline
|
|
46
|
-
#else
|
|
47
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
|
48
|
-
#endif
|
|
49
41
|
|
|
50
42
|
|
|
51
43
|
/****************************************************************
|
|
@@ -87,24 +79,6 @@ extern "C" {
|
|
|
87
79
|
/****************************************************************
|
|
88
80
|
* Memory I/O
|
|
89
81
|
*****************************************************************/
|
|
90
|
-
/* MEM_FORCE_MEMORY_ACCESS
|
|
91
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
|
92
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
|
93
|
-
* The below switch allow to select different access method for improved performance.
|
|
94
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
|
95
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
|
96
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
|
97
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
|
98
|
-
* It can generate buggy code on targets generating assembly depending on alignment.
|
|
99
|
-
* But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
|
100
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
|
101
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
|
102
|
-
*/
|
|
103
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
|
104
|
-
# if defined(__INTEL_COMPILER) || defined(__GNUC__) || defined(__ICCARM__)
|
|
105
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
|
106
|
-
# endif
|
|
107
|
-
#endif
|
|
108
82
|
|
|
109
83
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; }
|
|
110
84
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; }
|
|
@@ -115,33 +89,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
|
115
89
|
return one.c[0];
|
|
116
90
|
}
|
|
117
91
|
|
|
118
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
|
119
|
-
|
|
120
|
-
/* violates C standard on structure alignment.
|
|
121
|
-
Only use if no other choice to achieve best performance on target platform */
|
|
122
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
|
123
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
124
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
|
125
|
-
|
|
126
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
|
127
|
-
|
|
128
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
|
129
|
-
|
|
130
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
|
131
|
-
/* currently only defined for gcc and icc */
|
|
132
|
-
typedef union { U16 u16; U32 u32; U64 u64; } __attribute__((packed)) unalign;
|
|
133
|
-
|
|
134
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
|
135
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
|
136
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
137
|
-
|
|
138
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
|
139
|
-
|
|
140
|
-
#else
|
|
141
|
-
|
|
142
|
-
/* default method, safe and standard.
|
|
143
|
-
can sometimes prove slower */
|
|
144
|
-
|
|
145
92
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
|
146
93
|
{
|
|
147
94
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
|
@@ -162,9 +109,6 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
|
|
|
162
109
|
memcpy(memPtr, &value, sizeof(value));
|
|
163
110
|
}
|
|
164
111
|
|
|
165
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
|
166
|
-
|
|
167
|
-
|
|
168
112
|
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
|
|
169
113
|
{
|
|
170
114
|
if (MEM_isLittleEndian())
|
|
@@ -542,7 +486,7 @@ If there is an error, the function will return an error code, which can be teste
|
|
|
542
486
|
header file (to include)
|
|
543
487
|
Copyright (C) 2013-2015, Yann Collet.
|
|
544
488
|
|
|
545
|
-
BSD 2-Clause License (
|
|
489
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
546
490
|
|
|
547
491
|
Redistribution and use in source and binary forms, with or without
|
|
548
492
|
modification, are permitted provided that the following conditions are
|
|
@@ -700,7 +644,7 @@ MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
700
644
|
}
|
|
701
645
|
|
|
702
646
|
/*! BIT_lookBitsFast :
|
|
703
|
-
* unsafe version; only works
|
|
647
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
704
648
|
MEM_STATIC size_t BIT_lookBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
705
649
|
{
|
|
706
650
|
const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
|
@@ -720,7 +664,7 @@ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
720
664
|
}
|
|
721
665
|
|
|
722
666
|
/*!BIT_readBitsFast :
|
|
723
|
-
* unsafe version; only works
|
|
667
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
724
668
|
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
725
669
|
{
|
|
726
670
|
size_t value = BIT_lookBitsFast(bitD, nbBits);
|
|
@@ -781,7 +725,7 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
|
|
781
725
|
header file for static linking (only)
|
|
782
726
|
Copyright (C) 2013-2015, Yann Collet
|
|
783
727
|
|
|
784
|
-
BSD 2-Clause License (
|
|
728
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
785
729
|
|
|
786
730
|
Redistribution and use in source and binary forms, with or without
|
|
787
731
|
modification, are permitted provided that the following conditions are
|
|
@@ -930,7 +874,7 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
|
|
|
930
874
|
FSE : Finite State Entropy coder
|
|
931
875
|
Copyright (C) 2013-2015, Yann Collet.
|
|
932
876
|
|
|
933
|
-
BSD 2-Clause License (
|
|
877
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
934
878
|
|
|
935
879
|
Redistribution and use in source and binary forms, with or without
|
|
936
880
|
modification, are permitted provided that the following conditions are
|
|
@@ -1436,7 +1380,7 @@ static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, siz
|
|
|
1436
1380
|
header file
|
|
1437
1381
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1438
1382
|
|
|
1439
|
-
BSD 2-Clause License (
|
|
1383
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1440
1384
|
|
|
1441
1385
|
Redistribution and use in source and binary forms, with or without
|
|
1442
1386
|
modification, are permitted provided that the following conditions are
|
|
@@ -1514,7 +1458,7 @@ static unsigned HUF_isError(size_t code); /* tells if a return value i
|
|
|
1514
1458
|
header file for static linking (only)
|
|
1515
1459
|
Copyright (C) 2013-2015, Yann Collet
|
|
1516
1460
|
|
|
1517
|
-
BSD 2-Clause License (
|
|
1461
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1518
1462
|
|
|
1519
1463
|
Redistribution and use in source and binary forms, with or without
|
|
1520
1464
|
modification, are permitted provided that the following conditions are
|
|
@@ -1601,7 +1545,7 @@ static size_t HUF_decompress4X4_usingDTable(void* dst, size_t maxDstSize, const
|
|
|
1601
1545
|
Huff0 : Huffman coder, part of New Generation Entropy library
|
|
1602
1546
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1603
1547
|
|
|
1604
|
-
BSD 2-Clause License (
|
|
1548
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1605
1549
|
|
|
1606
1550
|
Redistribution and use in source and binary forms, with or without
|
|
1607
1551
|
modification, are permitted provided that the following conditions are
|
|
@@ -2401,7 +2345,7 @@ static size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_
|
|
|
2401
2345
|
zstd - decompression module fo v0.4 legacy format
|
|
2402
2346
|
Copyright (C) 2015-2016, Yann Collet.
|
|
2403
2347
|
|
|
2404
|
-
BSD 2-Clause License (
|
|
2348
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2405
2349
|
|
|
2406
2350
|
Redistribution and use in source and binary forms, with or without
|
|
2407
2351
|
modification, are permitted provided that the following conditions are
|
|
@@ -2876,13 +2820,19 @@ static size_t ZSTD_execSequence(BYTE* op,
|
|
|
2876
2820
|
const BYTE* const litEnd = *litPtr + sequence.litLength;
|
|
2877
2821
|
const BYTE* match = oLitEnd - sequence.offset;
|
|
2878
2822
|
|
|
2879
|
-
/*
|
|
2880
|
-
|
|
2823
|
+
/* checks */
|
|
2824
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
|
2825
|
+
|
|
2826
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
|
2827
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
|
2828
|
+
/* Now we know there are no overflow in literal nor match lengths, can use pointer checks */
|
|
2829
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
|
2830
|
+
|
|
2881
2831
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
|
2882
|
-
if (litEnd > litLimit) return ERROR(corruption_detected); /*
|
|
2832
|
+
if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
|
2883
2833
|
|
|
2884
2834
|
/* copy Literals */
|
|
2885
|
-
ZSTD_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
2835
|
+
ZSTD_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
2886
2836
|
op = oLitEnd;
|
|
2887
2837
|
*litPtr = litEnd; /* update for next sequence */
|
|
2888
2838
|
|
|
@@ -3260,6 +3210,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
|
3260
3210
|
}
|
|
3261
3211
|
ctx->stage = ZSTDds_decodeBlockHeader;
|
|
3262
3212
|
ctx->expected = ZSTD_blockHeaderSize;
|
|
3213
|
+
if (ZSTD_isError(rSize)) return rSize;
|
|
3263
3214
|
ctx->previousDstEnd = (char*)dst + rSize;
|
|
3264
3215
|
return rSize;
|
|
3265
3216
|
}
|
|
@@ -3283,7 +3234,7 @@ static void ZSTD_decompress_insertDictionary(ZSTD_DCtx* ctx, const void* dict, s
|
|
|
3283
3234
|
Buffered version of Zstd compression library
|
|
3284
3235
|
Copyright (C) 2015, Yann Collet.
|
|
3285
3236
|
|
|
3286
|
-
BSD 2-Clause License (
|
|
3237
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
3287
3238
|
|
|
3288
3239
|
Redistribution and use in source and binary forms, with or without
|
|
3289
3240
|
modification, are permitted provided that the following conditions are
|
|
@@ -3587,8 +3538,8 @@ static size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbc, void* dst, size_t* maxDs
|
|
|
3587
3538
|
unsigned ZBUFFv04_isError(size_t errorCode) { return ERR_isError(errorCode); }
|
|
3588
3539
|
const char* ZBUFFv04_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
|
|
3589
3540
|
|
|
3590
|
-
size_t ZBUFFv04_recommendedDInSize() { return BLOCKSIZE + 3; }
|
|
3591
|
-
size_t ZBUFFv04_recommendedDOutSize() { return BLOCKSIZE; }
|
|
3541
|
+
size_t ZBUFFv04_recommendedDInSize(void) { return BLOCKSIZE + 3; }
|
|
3542
|
+
size_t ZBUFFv04_recommendedDOutSize(void) { return BLOCKSIZE; }
|
|
3592
3543
|
|
|
3593
3544
|
|
|
3594
3545
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) Yann Collet,
|
|
2
|
+
* Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
low-level memory access routines
|
|
20
20
|
Copyright (C) 2013-2015, Yann Collet.
|
|
21
21
|
|
|
22
|
-
BSD 2-Clause License (
|
|
22
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
23
23
|
|
|
24
24
|
Redistribution and use in source and binary forms, with or without
|
|
25
25
|
modification, are permitted provided that the following conditions are
|
|
@@ -106,24 +106,6 @@ extern "C" {
|
|
|
106
106
|
/*-**************************************************************
|
|
107
107
|
* Memory I/O
|
|
108
108
|
*****************************************************************/
|
|
109
|
-
/* MEM_FORCE_MEMORY_ACCESS :
|
|
110
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
|
111
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
|
112
|
-
* The below switch allow to select different access method for improved performance.
|
|
113
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
|
114
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
|
115
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
|
116
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
|
117
|
-
* It can generate buggy code on targets depending on alignment.
|
|
118
|
-
* In some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
|
119
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
|
120
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
|
121
|
-
*/
|
|
122
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
|
123
|
-
# if defined(__INTEL_COMPILER) || defined(__GNUC__) || defined(__ICCARM__)
|
|
124
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
|
125
|
-
# endif
|
|
126
|
-
#endif
|
|
127
109
|
|
|
128
110
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; }
|
|
129
111
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; }
|
|
@@ -134,37 +116,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
|
134
116
|
return one.c[0];
|
|
135
117
|
}
|
|
136
118
|
|
|
137
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
|
138
|
-
|
|
139
|
-
/* violates C standard, by lying on structure alignment.
|
|
140
|
-
Only use if no other choice to achieve best performance on target platform */
|
|
141
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
|
142
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
143
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
|
144
|
-
|
|
145
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
|
146
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
|
|
147
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
|
|
148
|
-
|
|
149
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
|
150
|
-
|
|
151
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
|
152
|
-
/* currently only defined for gcc and icc */
|
|
153
|
-
typedef union { U16 u16; U32 u32; U64 u64; size_t st; } __attribute__((packed)) unalign;
|
|
154
|
-
|
|
155
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
|
156
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
|
157
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
158
|
-
|
|
159
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
|
160
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
|
|
161
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign*)memPtr)->u64 = value; }
|
|
162
|
-
|
|
163
|
-
#else
|
|
164
|
-
|
|
165
|
-
/* default method, safe and standard.
|
|
166
|
-
can sometimes prove slower */
|
|
167
|
-
|
|
168
119
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
|
169
120
|
{
|
|
170
121
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
|
@@ -195,9 +146,6 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value)
|
|
|
195
146
|
memcpy(memPtr, &value, sizeof(value));
|
|
196
147
|
}
|
|
197
148
|
|
|
198
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
|
199
|
-
|
|
200
|
-
|
|
201
149
|
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
|
|
202
150
|
{
|
|
203
151
|
if (MEM_isLittleEndian())
|
|
@@ -262,7 +210,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
262
210
|
Header File for static linking only
|
|
263
211
|
Copyright (C) 2014-2016, Yann Collet.
|
|
264
212
|
|
|
265
|
-
BSD 2-Clause License (
|
|
213
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
266
214
|
|
|
267
215
|
Redistribution and use in source and binary forms, with or without
|
|
268
216
|
modification, are permitted provided that the following conditions are
|
|
@@ -286,7 +234,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
286
234
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
287
235
|
|
|
288
236
|
You can contact the author at :
|
|
289
|
-
- zstd homepage :
|
|
237
|
+
- zstd homepage : https://facebook.github.io/zstd
|
|
290
238
|
*/
|
|
291
239
|
#ifndef ZSTD_STATIC_H
|
|
292
240
|
#define ZSTD_STATIC_H
|
|
@@ -398,7 +346,7 @@ size_t ZSTDv05_decompressBlock(ZSTDv05_DCtx* dctx, void* dst, size_t dstCapacity
|
|
|
398
346
|
Header File for include
|
|
399
347
|
Copyright (C) 2014-2016, Yann Collet.
|
|
400
348
|
|
|
401
|
-
BSD 2-Clause License (
|
|
349
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
402
350
|
|
|
403
351
|
Redistribution and use in source and binary forms, with or without
|
|
404
352
|
modification, are permitted provided that the following conditions are
|
|
@@ -485,7 +433,7 @@ static const size_t ZSTDv05_frameHeaderSize_min = 5;
|
|
|
485
433
|
#define FSEv05_ENCODING_DYNAMIC 3
|
|
486
434
|
|
|
487
435
|
|
|
488
|
-
#define
|
|
436
|
+
#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
|
|
489
437
|
|
|
490
438
|
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
|
491
439
|
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
|
|
@@ -543,7 +491,7 @@ typedef struct {
|
|
|
543
491
|
U32 litLengthSum;
|
|
544
492
|
U32 litSum;
|
|
545
493
|
U32 offCodeSum;
|
|
546
|
-
}
|
|
494
|
+
} SeqStore_t;
|
|
547
495
|
|
|
548
496
|
|
|
549
497
|
|
|
@@ -553,7 +501,7 @@ typedef struct {
|
|
|
553
501
|
header file
|
|
554
502
|
Copyright (C) 2013-2015, Yann Collet.
|
|
555
503
|
|
|
556
|
-
BSD 2-Clause License (
|
|
504
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
557
505
|
|
|
558
506
|
Redistribution and use in source and binary forms, with or without
|
|
559
507
|
modification, are permitted provided that the following conditions are
|
|
@@ -672,7 +620,7 @@ size_t FSEv05_decompress_usingDTable(void* dst, size_t dstCapacity, const void*
|
|
|
672
620
|
header file (to include)
|
|
673
621
|
Copyright (C) 2013-2016, Yann Collet.
|
|
674
622
|
|
|
675
|
-
BSD 2-Clause License (
|
|
623
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
676
624
|
|
|
677
625
|
Redistribution and use in source and binary forms, with or without
|
|
678
626
|
modification, are permitted provided that the following conditions are
|
|
@@ -826,7 +774,7 @@ MEM_STATIC size_t BITv05_lookBits(BITv05_DStream_t* bitD, U32 nbBits)
|
|
|
826
774
|
}
|
|
827
775
|
|
|
828
776
|
/*! BITv05_lookBitsFast :
|
|
829
|
-
* unsafe version; only works
|
|
777
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
830
778
|
MEM_STATIC size_t BITv05_lookBitsFast(BITv05_DStream_t* bitD, U32 nbBits)
|
|
831
779
|
{
|
|
832
780
|
const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
|
@@ -846,7 +794,7 @@ MEM_STATIC size_t BITv05_readBits(BITv05_DStream_t* bitD, unsigned nbBits)
|
|
|
846
794
|
}
|
|
847
795
|
|
|
848
796
|
/*!BITv05_readBitsFast :
|
|
849
|
-
* unsafe version; only works
|
|
797
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
850
798
|
MEM_STATIC size_t BITv05_readBitsFast(BITv05_DStream_t* bitD, unsigned nbBits)
|
|
851
799
|
{
|
|
852
800
|
size_t value = BITv05_lookBitsFast(bitD, nbBits);
|
|
@@ -901,7 +849,7 @@ MEM_STATIC unsigned BITv05_endOfDStream(const BITv05_DStream_t* DStream)
|
|
|
901
849
|
header file for static linking (only)
|
|
902
850
|
Copyright (C) 2013-2015, Yann Collet
|
|
903
851
|
|
|
904
|
-
BSD 2-Clause License (
|
|
852
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
905
853
|
|
|
906
854
|
Redistribution and use in source and binary forms, with or without
|
|
907
855
|
modification, are permitted provided that the following conditions are
|
|
@@ -1051,7 +999,7 @@ MEM_STATIC unsigned FSEv05_endOfDState(const FSEv05_DState_t* DStatePtr)
|
|
|
1051
999
|
FSEv05 : Finite State Entropy coder
|
|
1052
1000
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1053
1001
|
|
|
1054
|
-
BSD 2-Clause License (
|
|
1002
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1055
1003
|
|
|
1056
1004
|
Redistribution and use in source and binary forms, with or without
|
|
1057
1005
|
modification, are permitted provided that the following conditions are
|
|
@@ -1537,7 +1485,7 @@ size_t FSEv05_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t
|
|
|
1537
1485
|
header file
|
|
1538
1486
|
Copyright (C) 2013-2016, Yann Collet.
|
|
1539
1487
|
|
|
1540
|
-
BSD 2-Clause License (
|
|
1488
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1541
1489
|
|
|
1542
1490
|
Redistribution and use in source and binary forms, with or without
|
|
1543
1491
|
modification, are permitted provided that the following conditions are
|
|
@@ -1610,7 +1558,7 @@ const char* HUFv05_getErrorName(size_t code); /* provides error code string (u
|
|
|
1610
1558
|
header file, for static linking only
|
|
1611
1559
|
Copyright (C) 2013-2016, Yann Collet
|
|
1612
1560
|
|
|
1613
|
-
BSD 2-Clause License (
|
|
1561
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1614
1562
|
|
|
1615
1563
|
Redistribution and use in source and binary forms, with or without
|
|
1616
1564
|
modification, are permitted provided that the following conditions are
|
|
@@ -1702,7 +1650,7 @@ size_t HUFv05_decompress1X4_usingDTable(void* dst, size_t maxDstSize, const void
|
|
|
1702
1650
|
Huff0 : Huffman coder, part of New Generation Entropy library
|
|
1703
1651
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1704
1652
|
|
|
1705
|
-
BSD 2-Clause License (
|
|
1653
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1706
1654
|
|
|
1707
1655
|
Redistribution and use in source and binary forms, with or without
|
|
1708
1656
|
modification, are permitted provided that the following conditions are
|
|
@@ -2547,7 +2495,7 @@ size_t HUFv05_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
|
2547
2495
|
zstd - standard compression library
|
|
2548
2496
|
Copyright (C) 2014-2016, Yann Collet.
|
|
2549
2497
|
|
|
2550
|
-
BSD 2-Clause License (
|
|
2498
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2551
2499
|
|
|
2552
2500
|
Redistribution and use in source and binary forms, with or without
|
|
2553
2501
|
modification, are permitted provided that the following conditions are
|
|
@@ -2645,7 +2593,7 @@ struct ZSTDv05_DCtx_s
|
|
|
2645
2593
|
FSEv05_DTable LLTable[FSEv05_DTABLE_SIZE_U32(LLFSEv05Log)];
|
|
2646
2594
|
FSEv05_DTable OffTable[FSEv05_DTABLE_SIZE_U32(OffFSEv05Log)];
|
|
2647
2595
|
FSEv05_DTable MLTable[FSEv05_DTABLE_SIZE_U32(MLFSEv05Log)];
|
|
2648
|
-
unsigned hufTableX4[HUFv05_DTABLE_SIZE(
|
|
2596
|
+
unsigned hufTableX4[HUFv05_DTABLE_SIZE(ZSTD_HUFFDTABLE_CAPACITY_LOG)];
|
|
2649
2597
|
const void* previousDstEnd;
|
|
2650
2598
|
const void* base;
|
|
2651
2599
|
const void* vBase;
|
|
@@ -2673,7 +2621,7 @@ size_t ZSTDv05_decompressBegin(ZSTDv05_DCtx* dctx)
|
|
|
2673
2621
|
dctx->base = NULL;
|
|
2674
2622
|
dctx->vBase = NULL;
|
|
2675
2623
|
dctx->dictEnd = NULL;
|
|
2676
|
-
dctx->hufTableX4[0] =
|
|
2624
|
+
dctx->hufTableX4[0] = ZSTD_HUFFDTABLE_CAPACITY_LOG;
|
|
2677
2625
|
dctx->flagStaticTables = 0;
|
|
2678
2626
|
return 0;
|
|
2679
2627
|
}
|
|
@@ -3234,13 +3182,19 @@ static size_t ZSTDv05_execSequence(BYTE* op,
|
|
|
3234
3182
|
const BYTE* const litEnd = *litPtr + sequence.litLength;
|
|
3235
3183
|
const BYTE* match = oLitEnd - sequence.offset;
|
|
3236
3184
|
|
|
3237
|
-
/*
|
|
3238
|
-
|
|
3185
|
+
/* checks */
|
|
3186
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
|
3187
|
+
|
|
3188
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
|
3189
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
|
3190
|
+
/* Now we know there are no overflow in literal nor match lengths, can use pointer checks */
|
|
3191
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
|
3192
|
+
|
|
3239
3193
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
|
3240
|
-
if (litEnd > litLimit) return ERROR(corruption_detected); /*
|
|
3194
|
+
if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
|
3241
3195
|
|
|
3242
3196
|
/* copy Literals */
|
|
3243
|
-
ZSTDv05_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3197
|
+
ZSTDv05_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3244
3198
|
op = oLitEnd;
|
|
3245
3199
|
*litPtr = litEnd; /* update for next sequence */
|
|
3246
3200
|
|
|
@@ -3646,6 +3600,7 @@ size_t ZSTDv05_decompressContinue(ZSTDv05_DCtx* dctx, void* dst, size_t maxDstSi
|
|
|
3646
3600
|
}
|
|
3647
3601
|
dctx->stage = ZSTDv05ds_decodeBlockHeader;
|
|
3648
3602
|
dctx->expected = ZSTDv05_blockHeaderSize;
|
|
3603
|
+
if (ZSTDv05_isError(rSize)) return rSize;
|
|
3649
3604
|
dctx->previousDstEnd = (char*)dst + rSize;
|
|
3650
3605
|
return rSize;
|
|
3651
3606
|
}
|
|
@@ -3746,7 +3701,7 @@ size_t ZSTDv05_decompressBegin_usingDict(ZSTDv05_DCtx* dctx, const void* dict, s
|
|
|
3746
3701
|
Buffered version of Zstd compression library
|
|
3747
3702
|
Copyright (C) 2015-2016, Yann Collet.
|
|
3748
3703
|
|
|
3749
|
-
BSD 2-Clause License (
|
|
3704
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
3750
3705
|
|
|
3751
3706
|
Redistribution and use in source and binary forms, with or without
|
|
3752
3707
|
modification, are permitted provided that the following conditions are
|