extzstd 0.3.2 → 0.3.3
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/README.md +3 -3
- data/contrib/zstd/CHANGELOG +188 -1
- data/contrib/zstd/CONTRIBUTING.md +157 -74
- data/contrib/zstd/LICENSE +4 -4
- data/contrib/zstd/Makefile +81 -58
- data/contrib/zstd/Package.swift +36 -0
- data/contrib/zstd/README.md +59 -35
- data/contrib/zstd/TESTING.md +2 -3
- data/contrib/zstd/appveyor.yml +49 -136
- data/contrib/zstd/lib/BUCK +5 -7
- data/contrib/zstd/lib/Makefile +87 -181
- data/contrib/zstd/lib/README.md +23 -6
- data/contrib/zstd/lib/common/allocations.h +55 -0
- data/contrib/zstd/lib/common/bits.h +200 -0
- data/contrib/zstd/lib/common/bitstream.h +33 -59
- data/contrib/zstd/lib/common/compiler.h +115 -45
- data/contrib/zstd/lib/common/cpu.h +1 -1
- data/contrib/zstd/lib/common/debug.c +1 -1
- data/contrib/zstd/lib/common/debug.h +1 -1
- data/contrib/zstd/lib/common/entropy_common.c +15 -37
- data/contrib/zstd/lib/common/error_private.c +9 -2
- data/contrib/zstd/lib/common/error_private.h +82 -3
- data/contrib/zstd/lib/common/fse.h +9 -85
- data/contrib/zstd/lib/common/fse_decompress.c +29 -111
- data/contrib/zstd/lib/common/huf.h +84 -172
- data/contrib/zstd/lib/common/mem.h +58 -49
- data/contrib/zstd/lib/common/pool.c +37 -16
- data/contrib/zstd/lib/common/pool.h +9 -3
- data/contrib/zstd/lib/common/portability_macros.h +156 -0
- data/contrib/zstd/lib/common/threading.c +68 -14
- data/contrib/zstd/lib/common/threading.h +5 -10
- data/contrib/zstd/lib/common/xxhash.c +7 -809
- data/contrib/zstd/lib/common/xxhash.h +5568 -167
- data/contrib/zstd/lib/common/zstd_common.c +1 -36
- data/contrib/zstd/lib/common/zstd_deps.h +1 -1
- data/contrib/zstd/lib/common/zstd_internal.h +64 -150
- data/contrib/zstd/lib/common/zstd_trace.h +163 -0
- data/contrib/zstd/lib/compress/clevels.h +134 -0
- data/contrib/zstd/lib/compress/fse_compress.c +69 -150
- data/contrib/zstd/lib/compress/hist.c +1 -1
- data/contrib/zstd/lib/compress/hist.h +1 -1
- data/contrib/zstd/lib/compress/huf_compress.c +773 -251
- data/contrib/zstd/lib/compress/zstd_compress.c +2650 -826
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +509 -180
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +117 -40
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +28 -19
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +33 -305
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/contrib/zstd/lib/compress/zstd_cwksp.h +266 -85
- data/contrib/zstd/lib/compress/zstd_double_fast.c +369 -132
- data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_fast.c +722 -258
- data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_lazy.c +1105 -360
- data/contrib/zstd/lib/compress/zstd_lazy.h +41 -1
- data/contrib/zstd/lib/compress/zstd_ldm.c +272 -208
- data/contrib/zstd/lib/compress/zstd_ldm.h +3 -2
- data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +324 -197
- data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
- data/contrib/zstd/lib/compress/zstdmt_compress.c +109 -53
- data/contrib/zstd/lib/compress/zstdmt_compress.h +9 -6
- data/contrib/zstd/lib/decompress/huf_decompress.c +1071 -539
- data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +4 -4
- data/contrib/zstd/lib/decompress/zstd_ddict.h +1 -1
- data/contrib/zstd/lib/decompress/zstd_decompress.c +507 -82
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +962 -310
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +14 -3
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +54 -6
- data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/contrib/zstd/lib/dictBuilder/cover.c +44 -32
- data/contrib/zstd/lib/dictBuilder/cover.h +6 -5
- data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
- data/contrib/zstd/lib/dictBuilder/fastcover.c +24 -16
- data/contrib/zstd/lib/dictBuilder/zdict.c +88 -95
- data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
- data/contrib/zstd/lib/legacy/zstd_v01.c +16 -53
- data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v02.c +24 -69
- data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v03.c +25 -72
- data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v04.c +23 -69
- data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v05.c +35 -85
- data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v06.c +42 -87
- data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v07.c +35 -82
- data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
- data/contrib/zstd/lib/libzstd.mk +214 -0
- data/contrib/zstd/lib/libzstd.pc.in +4 -3
- data/contrib/zstd/lib/module.modulemap +35 -0
- data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +202 -33
- data/contrib/zstd/lib/zstd.h +922 -293
- data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +27 -8
- data/ext/extconf.rb +7 -6
- data/ext/extzstd.c +13 -10
- data/ext/libzstd_conf.h +0 -1
- data/ext/zstd_decompress_asm.S +1 -0
- metadata +16 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c)
|
|
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
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
low-level memory access routines
|
|
24
24
|
Copyright (C) 2013-2015, Yann Collet.
|
|
25
25
|
|
|
26
|
-
BSD 2-Clause License (
|
|
26
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
27
27
|
|
|
28
28
|
Redistribution and use in source and binary forms, with or without
|
|
29
29
|
modification, are permitted provided that the following conditions are
|
|
@@ -108,27 +108,6 @@ extern "C" {
|
|
|
108
108
|
/*-**************************************************************
|
|
109
109
|
* Memory I/O
|
|
110
110
|
*****************************************************************/
|
|
111
|
-
/* MEM_FORCE_MEMORY_ACCESS :
|
|
112
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
|
113
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
|
114
|
-
* The below switch allow to select different access method for improved performance.
|
|
115
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
|
116
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
|
117
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
|
118
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
|
119
|
-
* It can generate buggy code on targets depending on alignment.
|
|
120
|
-
* In some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
|
121
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
|
122
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
|
123
|
-
*/
|
|
124
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
|
125
|
-
# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
|
|
126
|
-
# define MEM_FORCE_MEMORY_ACCESS 2
|
|
127
|
-
# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
|
|
128
|
-
(defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
|
|
129
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
|
130
|
-
# endif
|
|
131
|
-
#endif
|
|
132
111
|
|
|
133
112
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(size_t)==4; }
|
|
134
113
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; }
|
|
@@ -139,33 +118,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
|
139
118
|
return one.c[0];
|
|
140
119
|
}
|
|
141
120
|
|
|
142
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
|
143
|
-
|
|
144
|
-
/* violates C standard, by lying on structure alignment.
|
|
145
|
-
Only use if no other choice to achieve best performance on target platform */
|
|
146
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
|
147
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
148
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
|
149
|
-
|
|
150
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
|
151
|
-
|
|
152
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
|
153
|
-
|
|
154
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
|
155
|
-
/* currently only defined for gcc and icc */
|
|
156
|
-
typedef union { U16 u16; U32 u32; U64 u64; size_t st; } __attribute__((packed)) unalign;
|
|
157
|
-
|
|
158
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
|
159
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
|
160
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
161
|
-
|
|
162
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
|
163
|
-
|
|
164
|
-
#else
|
|
165
|
-
|
|
166
|
-
/* default method, safe and standard.
|
|
167
|
-
can sometimes prove slower */
|
|
168
|
-
|
|
169
121
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
|
170
122
|
{
|
|
171
123
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
|
@@ -186,9 +138,6 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
|
|
|
186
138
|
memcpy(memPtr, &value, sizeof(value));
|
|
187
139
|
}
|
|
188
140
|
|
|
189
|
-
|
|
190
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
|
191
|
-
|
|
192
141
|
MEM_STATIC U32 MEM_swap32(U32 in)
|
|
193
142
|
{
|
|
194
143
|
#if defined(_MSC_VER) /* Visual Studio */
|
|
@@ -284,7 +233,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
284
233
|
Header File for static linking only
|
|
285
234
|
Copyright (C) 2014-2016, Yann Collet.
|
|
286
235
|
|
|
287
|
-
BSD 2-Clause License (
|
|
236
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
288
237
|
|
|
289
238
|
Redistribution and use in source and binary forms, with or without
|
|
290
239
|
modification, are permitted provided that the following conditions are
|
|
@@ -308,7 +257,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
308
257
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
309
258
|
|
|
310
259
|
You can contact the author at :
|
|
311
|
-
- zstd homepage :
|
|
260
|
+
- zstd homepage : https://facebook.github.io/zstd
|
|
312
261
|
*/
|
|
313
262
|
#ifndef ZSTDv06_STATIC_H
|
|
314
263
|
#define ZSTDv06_STATIC_H
|
|
@@ -415,7 +364,7 @@ ZSTDLIBv06_API size_t ZSTDv06_decompressBlock(ZSTDv06_DCtx* dctx, void* dst, siz
|
|
|
415
364
|
Header File for include
|
|
416
365
|
Copyright (C) 2014-2016, Yann Collet.
|
|
417
366
|
|
|
418
|
-
BSD 2-Clause License (
|
|
367
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
419
368
|
|
|
420
369
|
Redistribution and use in source and binary forms, with or without
|
|
421
370
|
modification, are permitted provided that the following conditions are
|
|
@@ -482,7 +431,7 @@ typedef enum { bt_compressed, bt_raw, bt_rle, bt_end } blockType_t;
|
|
|
482
431
|
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
|
483
432
|
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
|
|
484
433
|
|
|
485
|
-
#define
|
|
434
|
+
#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
|
|
486
435
|
|
|
487
436
|
#define IS_HUF 0
|
|
488
437
|
#define IS_PCH 1
|
|
@@ -622,7 +571,7 @@ void ZSTDv06_seqToCodes(const seqStore_t* seqStorePtr, size_t const nbSeq);
|
|
|
622
571
|
Public Prototypes declaration
|
|
623
572
|
Copyright (C) 2013-2016, Yann Collet.
|
|
624
573
|
|
|
625
|
-
BSD 2-Clause License (
|
|
574
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
626
575
|
|
|
627
576
|
Redistribution and use in source and binary forms, with or without
|
|
628
577
|
modification, are permitted provided that the following conditions are
|
|
@@ -770,7 +719,7 @@ If there is an error, the function will return an error code, which can be teste
|
|
|
770
719
|
header file (to include)
|
|
771
720
|
Copyright (C) 2013-2016, Yann Collet.
|
|
772
721
|
|
|
773
|
-
BSD 2-Clause License (
|
|
722
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
774
723
|
|
|
775
724
|
Redistribution and use in source and binary forms, with or without
|
|
776
725
|
modification, are permitted provided that the following conditions are
|
|
@@ -860,9 +809,8 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, unsigned nbBits);
|
|
|
860
809
|
MEM_STATIC unsigned BITv06_highbit32 ( U32 val)
|
|
861
810
|
{
|
|
862
811
|
# if defined(_MSC_VER) /* Visual */
|
|
863
|
-
unsigned long r
|
|
864
|
-
_BitScanReverse
|
|
865
|
-
return (unsigned) r;
|
|
812
|
+
unsigned long r;
|
|
813
|
+
return _BitScanReverse(&r, val) ? (unsigned)r : 0;
|
|
866
814
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
|
|
867
815
|
return __builtin_clz (val) ^ 31;
|
|
868
816
|
# else /* Software version */
|
|
@@ -932,7 +880,7 @@ MEM_STATIC size_t BITv06_initDStream(BITv06_DStream_t* bitD, const void* srcBuff
|
|
|
932
880
|
}
|
|
933
881
|
|
|
934
882
|
/*! BITv06_lookBitsFast() :
|
|
935
|
-
* unsafe version; only works
|
|
883
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
936
884
|
MEM_STATIC size_t BITv06_lookBitsFast(const BITv06_DStream_t* bitD, U32 nbBits)
|
|
937
885
|
{
|
|
938
886
|
U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
|
@@ -952,7 +900,7 @@ MEM_STATIC size_t BITv06_readBits(BITv06_DStream_t* bitD, U32 nbBits)
|
|
|
952
900
|
}
|
|
953
901
|
|
|
954
902
|
/*! BITv06_readBitsFast() :
|
|
955
|
-
* unsafe version; only works
|
|
903
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
956
904
|
MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, U32 nbBits)
|
|
957
905
|
{
|
|
958
906
|
size_t const value = BITv06_lookBitsFast(bitD, nbBits);
|
|
@@ -1006,7 +954,7 @@ MEM_STATIC unsigned BITv06_endOfDStream(const BITv06_DStream_t* DStream)
|
|
|
1006
954
|
header file for static linking (only)
|
|
1007
955
|
Copyright (C) 2013-2015, Yann Collet
|
|
1008
956
|
|
|
1009
|
-
BSD 2-Clause License (
|
|
957
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1010
958
|
|
|
1011
959
|
Redistribution and use in source and binary forms, with or without
|
|
1012
960
|
modification, are permitted provided that the following conditions are
|
|
@@ -1214,7 +1162,7 @@ MEM_STATIC BYTE FSEv06_decodeSymbolFast(FSEv06_DState_t* DStatePtr, BITv06_DStre
|
|
|
1214
1162
|
Common functions of New Generation Entropy library
|
|
1215
1163
|
Copyright (C) 2016, Yann Collet.
|
|
1216
1164
|
|
|
1217
|
-
BSD 2-Clause License (
|
|
1165
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1218
1166
|
|
|
1219
1167
|
Redistribution and use in source and binary forms, with or without
|
|
1220
1168
|
modification, are permitted provided that the following conditions are
|
|
@@ -1359,7 +1307,7 @@ size_t FSEv06_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned
|
|
|
1359
1307
|
FSE : Finite State Entropy decoder
|
|
1360
1308
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1361
1309
|
|
|
1362
|
-
BSD 2-Clause License (
|
|
1310
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1363
1311
|
|
|
1364
1312
|
Redistribution and use in source and binary forms, with or without
|
|
1365
1313
|
modification, are permitted provided that the following conditions are
|
|
@@ -1683,7 +1631,7 @@ size_t FSEv06_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t
|
|
|
1683
1631
|
header file
|
|
1684
1632
|
Copyright (C) 2013-2016, Yann Collet.
|
|
1685
1633
|
|
|
1686
|
-
BSD 2-Clause License (
|
|
1634
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1687
1635
|
|
|
1688
1636
|
Redistribution and use in source and binary forms, with or without
|
|
1689
1637
|
modification, are permitted provided that the following conditions are
|
|
@@ -1753,7 +1701,7 @@ size_t HUFv06_compressBound(size_t size); /**< maximum compressed size */
|
|
|
1753
1701
|
header file, for static linking only
|
|
1754
1702
|
Copyright (C) 2013-2016, Yann Collet
|
|
1755
1703
|
|
|
1756
|
-
BSD 2-Clause License (
|
|
1704
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1757
1705
|
|
|
1758
1706
|
Redistribution and use in source and binary forms, with or without
|
|
1759
1707
|
modification, are permitted provided that the following conditions are
|
|
@@ -1935,7 +1883,7 @@ MEM_STATIC size_t HUFv06_readStats(BYTE* huffWeight, size_t hwSize, U32* rankSta
|
|
|
1935
1883
|
Huffman decoder, part of New Generation Entropy library
|
|
1936
1884
|
Copyright (C) 2013-2016, Yann Collet.
|
|
1937
1885
|
|
|
1938
|
-
BSD 2-Clause License (
|
|
1886
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1939
1887
|
|
|
1940
1888
|
Redistribution and use in source and binary forms, with or without
|
|
1941
1889
|
modification, are permitted provided that the following conditions are
|
|
@@ -2680,7 +2628,7 @@ size_t HUFv06_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
|
2680
2628
|
Common functions of Zstd compression library
|
|
2681
2629
|
Copyright (C) 2015-2016, Yann Collet.
|
|
2682
2630
|
|
|
2683
|
-
BSD 2-Clause License (
|
|
2631
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2684
2632
|
|
|
2685
2633
|
Redistribution and use in source and binary forms, with or without
|
|
2686
2634
|
modification, are permitted provided that the following conditions are
|
|
@@ -2704,7 +2652,7 @@ size_t HUFv06_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
|
2704
2652
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2705
2653
|
|
|
2706
2654
|
You can contact the author at :
|
|
2707
|
-
- zstd homepage :
|
|
2655
|
+
- zstd homepage : https://facebook.github.io/zstd/
|
|
2708
2656
|
*/
|
|
2709
2657
|
|
|
2710
2658
|
|
|
@@ -2734,7 +2682,7 @@ const char* ZBUFFv06_getErrorName(size_t errorCode) { return ERR_getErrorName(er
|
|
|
2734
2682
|
zstd - standard compression library
|
|
2735
2683
|
Copyright (C) 2014-2016, Yann Collet.
|
|
2736
2684
|
|
|
2737
|
-
BSD 2-Clause License (
|
|
2685
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2738
2686
|
|
|
2739
2687
|
Redistribution and use in source and binary forms, with or without
|
|
2740
2688
|
modification, are permitted provided that the following conditions are
|
|
@@ -2758,7 +2706,7 @@ const char* ZBUFFv06_getErrorName(size_t errorCode) { return ERR_getErrorName(er
|
|
|
2758
2706
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2759
2707
|
|
|
2760
2708
|
You can contact the author at :
|
|
2761
|
-
- zstd homepage :
|
|
2709
|
+
- zstd homepage : https://facebook.github.io/zstd
|
|
2762
2710
|
*/
|
|
2763
2711
|
|
|
2764
2712
|
/* ***************************************************************
|
|
@@ -2810,7 +2758,7 @@ struct ZSTDv06_DCtx_s
|
|
|
2810
2758
|
FSEv06_DTable LLTable[FSEv06_DTABLE_SIZE_U32(LLFSELog)];
|
|
2811
2759
|
FSEv06_DTable OffTable[FSEv06_DTABLE_SIZE_U32(OffFSELog)];
|
|
2812
2760
|
FSEv06_DTable MLTable[FSEv06_DTABLE_SIZE_U32(MLFSELog)];
|
|
2813
|
-
unsigned hufTableX4[HUFv06_DTABLE_SIZE(
|
|
2761
|
+
unsigned hufTableX4[HUFv06_DTABLE_SIZE(ZSTD_HUFFDTABLE_CAPACITY_LOG)];
|
|
2814
2762
|
const void* previousDstEnd;
|
|
2815
2763
|
const void* base;
|
|
2816
2764
|
const void* vBase;
|
|
@@ -2838,7 +2786,7 @@ size_t ZSTDv06_decompressBegin(ZSTDv06_DCtx* dctx)
|
|
|
2838
2786
|
dctx->base = NULL;
|
|
2839
2787
|
dctx->vBase = NULL;
|
|
2840
2788
|
dctx->dictEnd = NULL;
|
|
2841
|
-
dctx->hufTableX4[0] =
|
|
2789
|
+
dctx->hufTableX4[0] = ZSTD_HUFFDTABLE_CAPACITY_LOG;
|
|
2842
2790
|
dctx->flagRepeatTable = 0;
|
|
2843
2791
|
return 0;
|
|
2844
2792
|
}
|
|
@@ -3029,7 +2977,7 @@ typedef struct
|
|
|
3029
2977
|
* Provides the size of compressed block from block header `src` */
|
|
3030
2978
|
static size_t ZSTDv06_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
|
|
3031
2979
|
{
|
|
3032
|
-
const BYTE* const in = (const BYTE*
|
|
2980
|
+
const BYTE* const in = (const BYTE*)src;
|
|
3033
2981
|
U32 cSize;
|
|
3034
2982
|
|
|
3035
2983
|
if (srcSize < ZSTDv06_blockHeaderSize) return ERROR(srcSize_wrong);
|
|
@@ -3223,7 +3171,7 @@ static size_t ZSTDv06_decodeSeqHeaders(int* nbSeqPtr,
|
|
|
3223
3171
|
FSEv06_DTable* DTableLL, FSEv06_DTable* DTableML, FSEv06_DTable* DTableOffb, U32 flagRepeatTable,
|
|
3224
3172
|
const void* src, size_t srcSize)
|
|
3225
3173
|
{
|
|
3226
|
-
const BYTE* const istart = (const BYTE*
|
|
3174
|
+
const BYTE* const istart = (const BYTE*)src;
|
|
3227
3175
|
const BYTE* const iend = istart + srcSize;
|
|
3228
3176
|
const BYTE* ip = istart;
|
|
3229
3177
|
|
|
@@ -3374,13 +3322,19 @@ static size_t ZSTDv06_execSequence(BYTE* op,
|
|
|
3374
3322
|
const BYTE* const iLitEnd = *litPtr + sequence.litLength;
|
|
3375
3323
|
const BYTE* match = oLitEnd - sequence.offset;
|
|
3376
3324
|
|
|
3377
|
-
/*
|
|
3378
|
-
|
|
3325
|
+
/* checks */
|
|
3326
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
|
3327
|
+
|
|
3328
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
|
3329
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
|
3330
|
+
/* Now we know there are no overflow in literal nor match lengths, can use pointer checks */
|
|
3331
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
|
3332
|
+
|
|
3379
3333
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
|
3380
|
-
if (iLitEnd > litLimit) return ERROR(corruption_detected); /*
|
|
3334
|
+
if (iLitEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
|
3381
3335
|
|
|
3382
3336
|
/* copy Literals */
|
|
3383
|
-
ZSTDv06_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3337
|
+
ZSTDv06_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3384
3338
|
op = oLitEnd;
|
|
3385
3339
|
*litPtr = iLitEnd; /* update for next sequence */
|
|
3386
3340
|
|
|
@@ -3445,7 +3399,7 @@ static size_t ZSTDv06_decompressSequences(
|
|
|
3445
3399
|
{
|
|
3446
3400
|
const BYTE* ip = (const BYTE*)seqStart;
|
|
3447
3401
|
const BYTE* const iend = ip + seqSize;
|
|
3448
|
-
BYTE* const ostart = (BYTE*
|
|
3402
|
+
BYTE* const ostart = (BYTE*)dst;
|
|
3449
3403
|
BYTE* const oend = ostart + maxDstSize;
|
|
3450
3404
|
BYTE* op = ostart;
|
|
3451
3405
|
const BYTE* litPtr = dctx->litPtr;
|
|
@@ -3561,7 +3515,7 @@ static size_t ZSTDv06_decompressFrame(ZSTDv06_DCtx* dctx,
|
|
|
3561
3515
|
{
|
|
3562
3516
|
const BYTE* ip = (const BYTE*)src;
|
|
3563
3517
|
const BYTE* const iend = ip + srcSize;
|
|
3564
|
-
BYTE* const ostart = (BYTE*
|
|
3518
|
+
BYTE* const ostart = (BYTE*)dst;
|
|
3565
3519
|
BYTE* op = ostart;
|
|
3566
3520
|
BYTE* const oend = ostart + dstCapacity;
|
|
3567
3521
|
size_t remainingSize = srcSize;
|
|
@@ -3893,7 +3847,7 @@ size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, s
|
|
|
3893
3847
|
Buffered version of Zstd compression library
|
|
3894
3848
|
Copyright (C) 2015-2016, Yann Collet.
|
|
3895
3849
|
|
|
3896
|
-
BSD 2-Clause License (
|
|
3850
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
3897
3851
|
|
|
3898
3852
|
Redistribution and use in source and binary forms, with or without
|
|
3899
3853
|
modification, are permitted provided that the following conditions are
|
|
@@ -3917,7 +3871,7 @@ size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, s
|
|
|
3917
3871
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3918
3872
|
|
|
3919
3873
|
You can contact the author at :
|
|
3920
|
-
- zstd homepage :
|
|
3874
|
+
- zstd homepage : https://facebook.github.io/zstd/
|
|
3921
3875
|
*/
|
|
3922
3876
|
|
|
3923
3877
|
|
|
@@ -4039,7 +3993,8 @@ size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* zbd,
|
|
|
4039
3993
|
size_t const toLoad = hSize - zbd->lhSize; /* if hSize!=0, hSize > zbd->lhSize */
|
|
4040
3994
|
if (ZSTDv06_isError(hSize)) return hSize;
|
|
4041
3995
|
if (toLoad > (size_t)(iend-ip)) { /* not enough input to load full header */
|
|
4042
|
-
|
|
3996
|
+
if (ip != NULL)
|
|
3997
|
+
memcpy(zbd->headerBuffer + zbd->lhSize, ip, iend-ip);
|
|
4043
3998
|
zbd->lhSize += iend-ip;
|
|
4044
3999
|
*dstCapacityPtr = 0;
|
|
4045
4000
|
return (hSize - zbd->lhSize) + ZSTDv06_blockHeaderSize; /* remaining header bytes + next block header */
|