zstdlib 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +10 -0
- data/README.md +7 -1
- data/Rakefile +38 -8
- data/ext/{zstdlib → zstdlib_c}/extconf.rb +10 -5
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-3.0/zstdlib.c +2 -2
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/adler32.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/compress.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzclose.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzguts.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzlib.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzread.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzwrite.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/infback.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffixed.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/uncompr.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zconf.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zlib.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +24 -9
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/compiler.h +89 -43
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/debug.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/entropy_common.c +11 -5
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.h +79 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +2 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +1 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +24 -22
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +18 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +11 -6
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +2 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +0 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_deps.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_internal.h +95 -92
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_trace.h +12 -3
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +63 -27
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/huf_compress.c +537 -104
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress.c +307 -373
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +174 -83
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +4 -3
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +3 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +15 -14
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.c +4 -3
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +41 -27
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +295 -120
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +309 -130
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_lazy.c +482 -562
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_lazy.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +9 -7
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +1 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm_geartab.h +4 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +249 -148
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +76 -38
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.h +4 -1
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/huf_decompress.c +727 -189
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +85 -22
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.c +744 -220
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +8 -2
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +34 -3
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zdict.h +4 -4
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +179 -136
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zstd_errors.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +7 -0
- data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +0 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.so +0 -0
- data/lib/2.5/zstdlib_c.so +0 -0
- data/lib/2.6/zstdlib_c.so +0 -0
- data/lib/2.7/zstdlib_c.so +0 -0
- data/lib/3.0/zstdlib_c.so +0 -0
- data/lib/3.1/zstdlib_c.so +0 -0
- data/lib/zstdlib.rb +2 -2
- metadata +125 -121
- data/ext/zstdlib/zstd-1.5.0/lib/common/xxhash.c +0 -824
- data/ext/zstdlib/zstd-1.5.0/lib/common/xxhash.h +0 -285
- data/ext/zstdlib/zstd.mk +0 -14
- data/lib/2.2/zstdlib.so +0 -0
- data/lib/2.3/zstdlib.so +0 -0
- data/lib/2.4/zstdlib.so +0 -0
- data/lib/2.5/zstdlib.so +0 -0
- data/lib/2.6/zstdlib.so +0 -0
- data/lib/2.7/zstdlib.so +0 -0
@@ -56,7 +56,6 @@
|
|
56
56
|
* Dependencies
|
57
57
|
*********************************************************/
|
58
58
|
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */
|
59
|
-
#include "../common/cpu.h" /* bmi2 */
|
60
59
|
#include "../common/mem.h" /* low level memory routines */
|
61
60
|
#define FSE_STATIC_LINKING_ONLY
|
62
61
|
#include "../common/fse.h"
|
@@ -177,12 +176,15 @@ static const ZSTD_DDict* ZSTD_DDictHashSet_getDDict(ZSTD_DDictHashSet* hashSet,
|
|
177
176
|
static ZSTD_DDictHashSet* ZSTD_createDDictHashSet(ZSTD_customMem customMem) {
|
178
177
|
ZSTD_DDictHashSet* ret = (ZSTD_DDictHashSet*)ZSTD_customMalloc(sizeof(ZSTD_DDictHashSet), customMem);
|
179
178
|
DEBUGLOG(4, "Allocating new hash set");
|
179
|
+
if (!ret)
|
180
|
+
return NULL;
|
180
181
|
ret->ddictPtrTable = (const ZSTD_DDict**)ZSTD_customCalloc(DDICT_HASHSET_TABLE_BASE_SIZE * sizeof(ZSTD_DDict*), customMem);
|
181
|
-
ret->
|
182
|
-
|
183
|
-
if (!ret || !ret->ddictPtrTable) {
|
182
|
+
if (!ret->ddictPtrTable) {
|
183
|
+
ZSTD_customFree(ret, customMem);
|
184
184
|
return NULL;
|
185
185
|
}
|
186
|
+
ret->ddictPtrTableSize = DDICT_HASHSET_TABLE_BASE_SIZE;
|
187
|
+
ret->ddictPtrCount = 0;
|
186
188
|
return ret;
|
187
189
|
}
|
188
190
|
|
@@ -255,11 +257,15 @@ static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
|
|
255
257
|
dctx->inBuffSize = 0;
|
256
258
|
dctx->outBuffSize = 0;
|
257
259
|
dctx->streamStage = zdss_init;
|
260
|
+
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
|
258
261
|
dctx->legacyContext = NULL;
|
259
262
|
dctx->previousLegacyVersion = 0;
|
263
|
+
#endif
|
260
264
|
dctx->noForwardProgress = 0;
|
261
265
|
dctx->oversizedDuration = 0;
|
262
|
-
|
266
|
+
#if DYNAMIC_BMI2
|
267
|
+
dctx->bmi2 = ZSTD_cpuSupportsBmi2();
|
268
|
+
#endif
|
263
269
|
dctx->ddictSet = NULL;
|
264
270
|
ZSTD_DCtx_resetParameters(dctx);
|
265
271
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
@@ -280,8 +286,7 @@ ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
|
|
280
286
|
return dctx;
|
281
287
|
}
|
282
288
|
|
283
|
-
ZSTD_DCtx*
|
284
|
-
{
|
289
|
+
static ZSTD_DCtx* ZSTD_createDCtx_internal(ZSTD_customMem customMem) {
|
285
290
|
if ((!customMem.customAlloc) ^ (!customMem.customFree)) return NULL;
|
286
291
|
|
287
292
|
{ ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_customMalloc(sizeof(*dctx), customMem);
|
@@ -292,10 +297,15 @@ ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
|
|
292
297
|
}
|
293
298
|
}
|
294
299
|
|
300
|
+
ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
|
301
|
+
{
|
302
|
+
return ZSTD_createDCtx_internal(customMem);
|
303
|
+
}
|
304
|
+
|
295
305
|
ZSTD_DCtx* ZSTD_createDCtx(void)
|
296
306
|
{
|
297
307
|
DEBUGLOG(3, "ZSTD_createDCtx");
|
298
|
-
return
|
308
|
+
return ZSTD_createDCtx_internal(ZSTD_defaultCMem);
|
299
309
|
}
|
300
310
|
|
301
311
|
static void ZSTD_clearDict(ZSTD_DCtx* dctx)
|
@@ -380,6 +390,19 @@ unsigned ZSTD_isFrame(const void* buffer, size_t size)
|
|
380
390
|
return 0;
|
381
391
|
}
|
382
392
|
|
393
|
+
/*! ZSTD_isSkippableFrame() :
|
394
|
+
* Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
|
395
|
+
* Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
|
396
|
+
*/
|
397
|
+
unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size)
|
398
|
+
{
|
399
|
+
if (size < ZSTD_FRAMEIDSIZE) return 0;
|
400
|
+
{ U32 const magic = MEM_readLE32(buffer);
|
401
|
+
if ((magic & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) return 1;
|
402
|
+
}
|
403
|
+
return 0;
|
404
|
+
}
|
405
|
+
|
383
406
|
/** ZSTD_frameHeaderSize_internal() :
|
384
407
|
* srcSize must be large enough to reach header size fields.
|
385
408
|
* note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless.
|
@@ -466,7 +489,9 @@ size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, s
|
|
466
489
|
}
|
467
490
|
switch(dictIDSizeCode)
|
468
491
|
{
|
469
|
-
default:
|
492
|
+
default:
|
493
|
+
assert(0); /* impossible */
|
494
|
+
ZSTD_FALLTHROUGH;
|
470
495
|
case 0 : break;
|
471
496
|
case 1 : dictID = ip[pos]; pos++; break;
|
472
497
|
case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break;
|
@@ -474,7 +499,9 @@ size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, s
|
|
474
499
|
}
|
475
500
|
switch(fcsID)
|
476
501
|
{
|
477
|
-
default:
|
502
|
+
default:
|
503
|
+
assert(0); /* impossible */
|
504
|
+
ZSTD_FALLTHROUGH;
|
478
505
|
case 0 : if (singleSegment) frameContentSize = ip[pos]; break;
|
479
506
|
case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break;
|
480
507
|
case 2 : frameContentSize = MEM_readLE32(ip+pos); break;
|
@@ -503,7 +530,6 @@ size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t src
|
|
503
530
|
return ZSTD_getFrameHeader_advanced(zfhPtr, src, srcSize, ZSTD_f_zstd1);
|
504
531
|
}
|
505
532
|
|
506
|
-
|
507
533
|
/** ZSTD_getFrameContentSize() :
|
508
534
|
* compatible with legacy mode
|
509
535
|
* @return : decompressed size of the single frame pointed to be `src` if known, otherwise
|
@@ -544,6 +570,37 @@ static size_t readSkippableFrameSize(void const* src, size_t srcSize)
|
|
544
570
|
}
|
545
571
|
}
|
546
572
|
|
573
|
+
/*! ZSTD_readSkippableFrame() :
|
574
|
+
* Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
575
|
+
*
|
576
|
+
* The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
|
577
|
+
* i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
|
578
|
+
* in the magicVariant.
|
579
|
+
*
|
580
|
+
* Returns an error if destination buffer is not large enough, or if the frame is not skippable.
|
581
|
+
*
|
582
|
+
* @return : number of bytes written or a ZSTD error.
|
583
|
+
*/
|
584
|
+
ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
|
585
|
+
const void* src, size_t srcSize)
|
586
|
+
{
|
587
|
+
U32 const magicNumber = MEM_readLE32(src);
|
588
|
+
size_t skippableFrameSize = readSkippableFrameSize(src, srcSize);
|
589
|
+
size_t skippableContentSize = skippableFrameSize - ZSTD_SKIPPABLEHEADERSIZE;
|
590
|
+
|
591
|
+
/* check input validity */
|
592
|
+
RETURN_ERROR_IF(!ZSTD_isSkippableFrame(src, srcSize), frameParameter_unsupported, "");
|
593
|
+
RETURN_ERROR_IF(skippableFrameSize < ZSTD_SKIPPABLEHEADERSIZE || skippableFrameSize > srcSize, srcSize_wrong, "");
|
594
|
+
RETURN_ERROR_IF(skippableContentSize > dstCapacity, dstSize_tooSmall, "");
|
595
|
+
|
596
|
+
/* deliver payload */
|
597
|
+
if (skippableContentSize > 0 && dst != NULL)
|
598
|
+
ZSTD_memcpy(dst, (const BYTE *)src + ZSTD_SKIPPABLEHEADERSIZE, skippableContentSize);
|
599
|
+
if (magicVariant != NULL)
|
600
|
+
*magicVariant = magicNumber - ZSTD_MAGIC_SKIPPABLE_START;
|
601
|
+
return skippableContentSize;
|
602
|
+
}
|
603
|
+
|
547
604
|
/** ZSTD_findDecompressedSize() :
|
548
605
|
* compatible with legacy mode
|
549
606
|
* `srcSize` must be the exact length of some number of ZSTD compressed and/or
|
@@ -858,7 +915,7 @@ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
|
|
858
915
|
switch(blockProperties.blockType)
|
859
916
|
{
|
860
917
|
case bt_compressed:
|
861
|
-
decodedSize = ZSTD_decompressBlock_internal(dctx, op, (size_t)(oend-op), ip, cBlockSize, /* frame */ 1);
|
918
|
+
decodedSize = ZSTD_decompressBlock_internal(dctx, op, (size_t)(oend-op), ip, cBlockSize, /* frame */ 1, not_streaming);
|
862
919
|
break;
|
863
920
|
case bt_raw :
|
864
921
|
decodedSize = ZSTD_copyRawBlock(op, (size_t)(oend-op), ip, cBlockSize);
|
@@ -1009,7 +1066,7 @@ static ZSTD_DDict const* ZSTD_getDDict(ZSTD_DCtx* dctx)
|
|
1009
1066
|
switch (dctx->dictUses) {
|
1010
1067
|
default:
|
1011
1068
|
assert(0 /* Impossible */);
|
1012
|
-
|
1069
|
+
ZSTD_FALLTHROUGH;
|
1013
1070
|
case ZSTD_dont_use:
|
1014
1071
|
ZSTD_clearDict(dctx);
|
1015
1072
|
return NULL;
|
@@ -1031,7 +1088,7 @@ size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t sr
|
|
1031
1088
|
{
|
1032
1089
|
#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1)
|
1033
1090
|
size_t regenSize;
|
1034
|
-
ZSTD_DCtx* const dctx =
|
1091
|
+
ZSTD_DCtx* const dctx = ZSTD_createDCtx_internal(ZSTD_defaultCMem);
|
1035
1092
|
RETURN_ERROR_IF(dctx==NULL, memory_allocation, "NULL pointer!");
|
1036
1093
|
regenSize = ZSTD_decompressDCtx(dctx, dst, dstCapacity, src, srcSize);
|
1037
1094
|
ZSTD_freeDCtx(dctx);
|
@@ -1065,7 +1122,7 @@ static size_t ZSTD_nextSrcSizeToDecompressWithInputSize(ZSTD_DCtx* dctx, size_t
|
|
1065
1122
|
return dctx->expected;
|
1066
1123
|
if (dctx->bType != bt_raw)
|
1067
1124
|
return dctx->expected;
|
1068
|
-
return
|
1125
|
+
return BOUNDED(1, inputSize, dctx->expected);
|
1069
1126
|
}
|
1070
1127
|
|
1071
1128
|
ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
|
@@ -1073,7 +1130,9 @@ ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
|
|
1073
1130
|
{
|
1074
1131
|
default: /* should not happen */
|
1075
1132
|
assert(0);
|
1133
|
+
ZSTD_FALLTHROUGH;
|
1076
1134
|
case ZSTDds_getFrameHeaderSize:
|
1135
|
+
ZSTD_FALLTHROUGH;
|
1077
1136
|
case ZSTDds_decodeFrameHeader:
|
1078
1137
|
return ZSTDnit_frameHeader;
|
1079
1138
|
case ZSTDds_decodeBlockHeader:
|
@@ -1085,6 +1144,7 @@ ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
|
|
1085
1144
|
case ZSTDds_checkChecksum:
|
1086
1145
|
return ZSTDnit_checksum;
|
1087
1146
|
case ZSTDds_decodeSkippableHeader:
|
1147
|
+
ZSTD_FALLTHROUGH;
|
1088
1148
|
case ZSTDds_skipFrame:
|
1089
1149
|
return ZSTDnit_skippableFrame;
|
1090
1150
|
}
|
@@ -1168,7 +1228,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
|
|
1168
1228
|
{
|
1169
1229
|
case bt_compressed:
|
1170
1230
|
DEBUGLOG(5, "ZSTD_decompressContinue: case bt_compressed");
|
1171
|
-
rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1);
|
1231
|
+
rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1, is_streaming);
|
1172
1232
|
dctx->expected = 0; /* Streaming not supported */
|
1173
1233
|
break;
|
1174
1234
|
case bt_raw :
|
@@ -1493,7 +1553,7 @@ size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
|
|
1493
1553
|
ZSTD_DStream* ZSTD_createDStream(void)
|
1494
1554
|
{
|
1495
1555
|
DEBUGLOG(3, "ZSTD_createDStream");
|
1496
|
-
return
|
1556
|
+
return ZSTD_createDCtx_internal(ZSTD_defaultCMem);
|
1497
1557
|
}
|
1498
1558
|
|
1499
1559
|
ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
|
@@ -1503,7 +1563,7 @@ ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
|
|
1503
1563
|
|
1504
1564
|
ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem)
|
1505
1565
|
{
|
1506
|
-
return
|
1566
|
+
return ZSTD_createDCtx_internal(customMem);
|
1507
1567
|
}
|
1508
1568
|
|
1509
1569
|
size_t ZSTD_freeDStream(ZSTD_DStream* zds)
|
@@ -1763,7 +1823,8 @@ size_t ZSTD_sizeof_DStream(const ZSTD_DStream* dctx)
|
|
1763
1823
|
size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
|
1764
1824
|
{
|
1765
1825
|
size_t const blockSize = (size_t) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
|
1766
|
-
|
1826
|
+
/* space is needed to store the litbuffer after the output of a given block without stomping the extDict of a previous run, as well as to cover both windows against wildcopy*/
|
1827
|
+
unsigned long long const neededRBSize = windowSize + blockSize + ZSTD_BLOCKSIZE_MAX + (WILDCOPY_OVERLENGTH * 2);
|
1767
1828
|
unsigned long long const neededSize = MIN(frameContentSize, neededRBSize);
|
1768
1829
|
size_t const minRBSize = (size_t) neededSize;
|
1769
1830
|
RETURN_ERROR_IF((unsigned long long)minRBSize != neededSize,
|
@@ -1897,10 +1958,12 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
|
1897
1958
|
DEBUGLOG(5, "stage zdss_init => transparent reset ");
|
1898
1959
|
zds->streamStage = zdss_loadHeader;
|
1899
1960
|
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
|
1961
|
+
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
|
1900
1962
|
zds->legacyVersion = 0;
|
1963
|
+
#endif
|
1901
1964
|
zds->hostageByte = 0;
|
1902
1965
|
zds->expectedOutBuffer = *output;
|
1903
|
-
|
1966
|
+
ZSTD_FALLTHROUGH;
|
1904
1967
|
|
1905
1968
|
case zdss_loadHeader :
|
1906
1969
|
DEBUGLOG(5, "stage zdss_loadHeader (srcSize : %u)", (U32)(iend - ip));
|
@@ -2038,7 +2101,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
|
2038
2101
|
zds->outBuffSize = neededOutBuffSize;
|
2039
2102
|
} } }
|
2040
2103
|
zds->streamStage = zdss_read;
|
2041
|
-
|
2104
|
+
ZSTD_FALLTHROUGH;
|
2042
2105
|
|
2043
2106
|
case zdss_read:
|
2044
2107
|
DEBUGLOG(5, "stage zdss_read");
|
@@ -2057,7 +2120,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
|
2057
2120
|
} }
|
2058
2121
|
if (ip==iend) { someMoreWork = 0; break; } /* no more input */
|
2059
2122
|
zds->streamStage = zdss_load;
|
2060
|
-
|
2123
|
+
ZSTD_FALLTHROUGH;
|
2061
2124
|
|
2062
2125
|
case zdss_load:
|
2063
2126
|
{ size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
|