zstd-ruby 1.4.1.0 → 1.4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +3 -574
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +24 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +149 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +29 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +415 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +47 -0
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +2 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +16 -13
- data/ext/zstdruby/libzstd/zstd.h +1 -1
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +6 -2
@@ -0,0 +1,47 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#ifndef ZSTD_COMPRESS_SEQUENCES_H
|
12
|
+
#define ZSTD_COMPRESS_SEQUENCES_H
|
13
|
+
|
14
|
+
#include "fse.h" /* FSE_repeat, FSE_CTable */
|
15
|
+
#include "zstd_internal.h" /* symbolEncodingType_e, ZSTD_strategy */
|
16
|
+
|
17
|
+
typedef enum {
|
18
|
+
ZSTD_defaultDisallowed = 0,
|
19
|
+
ZSTD_defaultAllowed = 1
|
20
|
+
} ZSTD_defaultPolicy_e;
|
21
|
+
|
22
|
+
symbolEncodingType_e
|
23
|
+
ZSTD_selectEncodingType(
|
24
|
+
FSE_repeat* repeatMode, unsigned const* count, unsigned const max,
|
25
|
+
size_t const mostFrequent, size_t nbSeq, unsigned const FSELog,
|
26
|
+
FSE_CTable const* prevCTable,
|
27
|
+
short const* defaultNorm, U32 defaultNormLog,
|
28
|
+
ZSTD_defaultPolicy_e const isDefaultAllowed,
|
29
|
+
ZSTD_strategy const strategy);
|
30
|
+
|
31
|
+
size_t
|
32
|
+
ZSTD_buildCTable(void* dst, size_t dstCapacity,
|
33
|
+
FSE_CTable* nextCTable, U32 FSELog, symbolEncodingType_e type,
|
34
|
+
unsigned* count, U32 max,
|
35
|
+
const BYTE* codeTable, size_t nbSeq,
|
36
|
+
const S16* defaultNorm, U32 defaultNormLog, U32 defaultMax,
|
37
|
+
const FSE_CTable* prevCTable, size_t prevCTableSize,
|
38
|
+
void* workspace, size_t workspaceSize);
|
39
|
+
|
40
|
+
size_t ZSTD_encodeSequences(
|
41
|
+
void* dst, size_t dstCapacity,
|
42
|
+
FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable,
|
43
|
+
FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable,
|
44
|
+
FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable,
|
45
|
+
seqDef const* sequences, size_t nbSeq, int longOffsets, int bmi2);
|
46
|
+
|
47
|
+
#endif /* ZSTD_COMPRESS_SEQUENCES_H */
|
@@ -909,6 +909,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
|
|
909
909
|
{ blockProperties_t bp;
|
910
910
|
size_t const cBlockSize = ZSTD_getcBlockSize(src, ZSTD_blockHeaderSize, &bp);
|
911
911
|
if (ZSTD_isError(cBlockSize)) return cBlockSize;
|
912
|
+
RETURN_ERROR_IF(cBlockSize > dctx->fParams.blockSizeMax, corruption_detected, "Block Size Exceeds Maximum");
|
912
913
|
dctx->expected = cBlockSize;
|
913
914
|
dctx->bType = bp.blockType;
|
914
915
|
dctx->rleSize = bp.origSize;
|
@@ -953,6 +954,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
|
|
953
954
|
RETURN_ERROR(corruption_detected);
|
954
955
|
}
|
955
956
|
if (ZSTD_isError(rSize)) return rSize;
|
957
|
+
RETURN_ERROR_IF(rSize > dctx->fParams.blockSizeMax, corruption_detected, "Decompressed Block Size Exceeds Maximum");
|
956
958
|
DEBUGLOG(5, "ZSTD_decompressContinue: decoded size from block : %u", (unsigned)rSize);
|
957
959
|
dctx->decodedSize += rSize;
|
958
960
|
if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize);
|
@@ -218,11 +218,6 @@ MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val)
|
|
218
218
|
}
|
219
219
|
}
|
220
220
|
|
221
|
-
MEM_STATIC U32 MEM_readLE24(const void* memPtr)
|
222
|
-
{
|
223
|
-
return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16);
|
224
|
-
}
|
225
|
-
|
226
221
|
MEM_STATIC U32 MEM_readLE32(const void* memPtr)
|
227
222
|
{
|
228
223
|
if (MEM_isLittleEndian())
|
@@ -3158,10 +3153,14 @@ static void ZSTDv05_decodeSequence(seq_t* seq, seqState_t* seqState)
|
|
3158
3153
|
if (litLength == MaxLL) {
|
3159
3154
|
const U32 add = *dumps++;
|
3160
3155
|
if (add < 255) litLength += add;
|
3161
|
-
else if (dumps +
|
3162
|
-
litLength =
|
3163
|
-
|
3164
|
-
|
3156
|
+
else if (dumps + 2 <= de) {
|
3157
|
+
litLength = MEM_readLE16(dumps);
|
3158
|
+
dumps += 2;
|
3159
|
+
if ((litLength & 1) && dumps < de) {
|
3160
|
+
litLength += *dumps << 16;
|
3161
|
+
dumps += 1;
|
3162
|
+
}
|
3163
|
+
litLength>>=1;
|
3165
3164
|
}
|
3166
3165
|
if (dumps >= de) { dumps = de-1; } /* late correction, to avoid read overflow (data is now corrupted anyway) */
|
3167
3166
|
}
|
@@ -3191,10 +3190,14 @@ static void ZSTDv05_decodeSequence(seq_t* seq, seqState_t* seqState)
|
|
3191
3190
|
if (matchLength == MaxML) {
|
3192
3191
|
const U32 add = dumps<de ? *dumps++ : 0;
|
3193
3192
|
if (add < 255) matchLength += add;
|
3194
|
-
else if (dumps +
|
3195
|
-
matchLength =
|
3196
|
-
|
3197
|
-
|
3193
|
+
else if (dumps + 2 <= de) {
|
3194
|
+
matchLength = MEM_readLE16(dumps);
|
3195
|
+
dumps += 2;
|
3196
|
+
if ((matchLength & 1) && dumps < de) {
|
3197
|
+
matchLength += *dumps << 16;
|
3198
|
+
dumps += 1;
|
3199
|
+
}
|
3200
|
+
matchLength >>= 1;
|
3198
3201
|
}
|
3199
3202
|
if (dumps >= de) { dumps = de-1; } /* late correction, to avoid read overflow (data is now corrupted anyway) */
|
3200
3203
|
}
|
data/ext/zstdruby/libzstd/zstd.h
CHANGED
@@ -71,7 +71,7 @@ extern "C" {
|
|
71
71
|
/*------ Version ------*/
|
72
72
|
#define ZSTD_VERSION_MAJOR 1
|
73
73
|
#define ZSTD_VERSION_MINOR 4
|
74
|
-
#define ZSTD_VERSION_RELEASE
|
74
|
+
#define ZSTD_VERSION_RELEASE 2
|
75
75
|
|
76
76
|
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
|
77
77
|
ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< to check runtime library version */
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zstd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,10 @@ files:
|
|
118
118
|
- ext/zstdruby/libzstd/compress/huf_compress.c
|
119
119
|
- ext/zstdruby/libzstd/compress/zstd_compress.c
|
120
120
|
- ext/zstdruby/libzstd/compress/zstd_compress_internal.h
|
121
|
+
- ext/zstdruby/libzstd/compress/zstd_compress_literals.c
|
122
|
+
- ext/zstdruby/libzstd/compress/zstd_compress_literals.h
|
123
|
+
- ext/zstdruby/libzstd/compress/zstd_compress_sequences.c
|
124
|
+
- ext/zstdruby/libzstd/compress/zstd_compress_sequences.h
|
121
125
|
- ext/zstdruby/libzstd/compress/zstd_double_fast.c
|
122
126
|
- ext/zstdruby/libzstd/compress/zstd_double_fast.h
|
123
127
|
- ext/zstdruby/libzstd/compress/zstd_fast.c
|