zstd-ruby 1.1.3.0 → 1.1.4.0
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 +1 -1
- data/ext/zstdruby/libzstd/Makefile +9 -6
- data/ext/zstdruby/libzstd/common/bitstream.h +3 -0
- data/ext/zstdruby/libzstd/common/entropy_common.c +13 -19
- data/ext/zstdruby/libzstd/common/fse.h +48 -22
- data/ext/zstdruby/libzstd/common/fse_decompress.c +0 -1
- data/ext/zstdruby/libzstd/common/huf.h +27 -5
- data/ext/zstdruby/libzstd/common/mem.h +14 -12
- data/ext/zstdruby/libzstd/common/threading.c +5 -4
- data/ext/zstdruby/libzstd/common/threading.h +1 -1
- data/ext/zstdruby/libzstd/common/xxhash.c +3 -1
- data/ext/zstdruby/libzstd/common/xxhash.h +11 -15
- data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +4 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +16 -9
- data/ext/zstdruby/libzstd/compress/huf_compress.c +103 -28
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +90 -37
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +7 -8
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +20 -17
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +429 -120
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +3 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +16 -8
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +1 -1
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +1 -0
- data/ext/zstdruby/libzstd/dll/libzstd.def +2 -0
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +122 -7
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +31 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +8 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +37 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +8 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +37 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +8 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +33 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +8 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +29 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +7 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +32 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +7 -0
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +44 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +8 -0
- data/ext/zstdruby/libzstd/zstd.h +87 -13
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +2 -2
@@ -32,6 +32,13 @@ extern "C" {
|
|
32
32
|
size_t ZSTDv05_decompress( void* dst, size_t dstCapacity,
|
33
33
|
const void* src, size_t compressedSize);
|
34
34
|
|
35
|
+
/**
|
36
|
+
ZSTDv05_getFrameSrcSize() : get the source length of a ZSTD frame
|
37
|
+
compressedSize : The size of the 'src' buffer, at least as large as the frame pointed to by 'src'
|
38
|
+
return : the number of bytes that would be read to decompress this frame
|
39
|
+
or an errorCode if it fails (which can be tested using ZSTDv05_isError())
|
40
|
+
*/
|
41
|
+
size_t ZSTDv05_findFrameCompressedSize(const void* src, size_t compressedSize);
|
35
42
|
|
36
43
|
/* *************************************
|
37
44
|
* Helper functions
|
@@ -3729,6 +3729,37 @@ size_t ZSTDv06_decompress(void* dst, size_t dstCapacity, const void* src, size_t
|
|
3729
3729
|
#endif
|
3730
3730
|
}
|
3731
3731
|
|
3732
|
+
size_t ZSTDv06_findFrameCompressedSize(const void* src, size_t srcSize)
|
3733
|
+
{
|
3734
|
+
const BYTE* ip = (const BYTE*)src;
|
3735
|
+
size_t remainingSize = srcSize;
|
3736
|
+
blockProperties_t blockProperties = { bt_compressed, 0 };
|
3737
|
+
|
3738
|
+
/* Frame Header */
|
3739
|
+
{ size_t const frameHeaderSize = ZSTDv06_frameHeaderSize(src, ZSTDv06_frameHeaderSize_min);
|
3740
|
+
if (ZSTDv06_isError(frameHeaderSize)) return frameHeaderSize;
|
3741
|
+
if (MEM_readLE32(src) != ZSTDv06_MAGICNUMBER) return ERROR(prefix_unknown);
|
3742
|
+
if (srcSize < frameHeaderSize+ZSTDv06_blockHeaderSize) return ERROR(srcSize_wrong);
|
3743
|
+
ip += frameHeaderSize; remainingSize -= frameHeaderSize;
|
3744
|
+
}
|
3745
|
+
|
3746
|
+
/* Loop on each block */
|
3747
|
+
while (1) {
|
3748
|
+
size_t const cBlockSize = ZSTDv06_getcBlockSize(ip, remainingSize, &blockProperties);
|
3749
|
+
if (ZSTDv06_isError(cBlockSize)) return cBlockSize;
|
3750
|
+
|
3751
|
+
ip += ZSTDv06_blockHeaderSize;
|
3752
|
+
remainingSize -= ZSTDv06_blockHeaderSize;
|
3753
|
+
if (cBlockSize > remainingSize) return ERROR(srcSize_wrong);
|
3754
|
+
|
3755
|
+
if (cBlockSize == 0) break; /* bt_end */
|
3756
|
+
|
3757
|
+
ip += cBlockSize;
|
3758
|
+
remainingSize -= cBlockSize;
|
3759
|
+
}
|
3760
|
+
|
3761
|
+
return ip - (const BYTE*)src;
|
3762
|
+
}
|
3732
3763
|
|
3733
3764
|
/*_******************************
|
3734
3765
|
* Streaming Decompression API
|
@@ -4077,7 +4108,7 @@ size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* zbd,
|
|
4077
4108
|
zbd->inBuff = (char*)malloc(blockSize);
|
4078
4109
|
if (zbd->inBuff == NULL) return ERROR(memory_allocation);
|
4079
4110
|
}
|
4080
|
-
{ size_t const neededOutSize = ((size_t)1 << zbd->fParams.windowLog) + blockSize;
|
4111
|
+
{ size_t const neededOutSize = ((size_t)1 << zbd->fParams.windowLog) + blockSize + WILDCOPY_OVERLENGTH * 2;
|
4081
4112
|
if (zbd->outBuffSize < neededOutSize) {
|
4082
4113
|
free(zbd->outBuff);
|
4083
4114
|
zbd->outBuffSize = neededOutSize;
|
@@ -41,6 +41,13 @@ extern "C" {
|
|
41
41
|
ZSTDLIBv06_API size_t ZSTDv06_decompress( void* dst, size_t dstCapacity,
|
42
42
|
const void* src, size_t compressedSize);
|
43
43
|
|
44
|
+
/**
|
45
|
+
ZSTDv06_getFrameSrcSize() : get the source length of a ZSTD frame
|
46
|
+
compressedSize : The size of the 'src' buffer, at least as large as the frame pointed to by 'src'
|
47
|
+
return : the number of bytes that would be read to decompress this frame
|
48
|
+
or an errorCode if it fails (which can be tested using ZSTDv06_isError())
|
49
|
+
*/
|
50
|
+
size_t ZSTDv06_findFrameCompressedSize(const void* src, size_t compressedSize);
|
44
51
|
|
45
52
|
/* *************************************
|
46
53
|
* Helper functions
|
@@ -13,12 +13,14 @@
|
|
13
13
|
#include <string.h> /* memcpy */
|
14
14
|
#include <stdlib.h> /* malloc, free, qsort */
|
15
15
|
|
16
|
-
#
|
17
|
-
#
|
16
|
+
#ifndef XXH_STATIC_LINKING_ONLY
|
17
|
+
# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
18
|
+
#endif
|
19
|
+
#include "xxhash.h" /* XXH64_* */
|
18
20
|
#include "zstd_v07.h"
|
19
21
|
|
20
|
-
#define FSEv07_STATIC_LINKING_ONLY
|
21
|
-
#define HUFv07_STATIC_LINKING_ONLY
|
22
|
+
#define FSEv07_STATIC_LINKING_ONLY /* FSEv07_MIN_TABLELOG */
|
23
|
+
#define HUFv07_STATIC_LINKING_ONLY /* HUFv07_TABLELOG_ABSOLUTEMAX */
|
22
24
|
#define ZSTDv07_STATIC_LINKING_ONLY
|
23
25
|
|
24
26
|
#include "error_private.h"
|
@@ -3968,6 +3970,41 @@ size_t ZSTDv07_decompress(void* dst, size_t dstCapacity, const void* src, size_t
|
|
3968
3970
|
#endif
|
3969
3971
|
}
|
3970
3972
|
|
3973
|
+
size_t ZSTDv07_findFrameCompressedSize(const void* src, size_t srcSize)
|
3974
|
+
{
|
3975
|
+
const BYTE* ip = (const BYTE*)src;
|
3976
|
+
size_t remainingSize = srcSize;
|
3977
|
+
|
3978
|
+
/* check */
|
3979
|
+
if (srcSize < ZSTDv07_frameHeaderSize_min+ZSTDv07_blockHeaderSize) return ERROR(srcSize_wrong);
|
3980
|
+
|
3981
|
+
/* Frame Header */
|
3982
|
+
{ size_t const frameHeaderSize = ZSTDv07_frameHeaderSize(src, ZSTDv07_frameHeaderSize_min);
|
3983
|
+
if (ZSTDv07_isError(frameHeaderSize)) return frameHeaderSize;
|
3984
|
+
if (MEM_readLE32(src) != ZSTDv07_MAGICNUMBER) return ERROR(prefix_unknown);
|
3985
|
+
if (srcSize < frameHeaderSize+ZSTDv07_blockHeaderSize) return ERROR(srcSize_wrong);
|
3986
|
+
ip += frameHeaderSize; remainingSize -= frameHeaderSize;
|
3987
|
+
}
|
3988
|
+
|
3989
|
+
/* Loop on each block */
|
3990
|
+
while (1) {
|
3991
|
+
blockProperties_t blockProperties;
|
3992
|
+
size_t const cBlockSize = ZSTDv07_getcBlockSize(ip, remainingSize, &blockProperties);
|
3993
|
+
if (ZSTDv07_isError(cBlockSize)) return cBlockSize;
|
3994
|
+
|
3995
|
+
ip += ZSTDv07_blockHeaderSize;
|
3996
|
+
remainingSize -= ZSTDv07_blockHeaderSize;
|
3997
|
+
|
3998
|
+
if (blockProperties.blockType == bt_end) break;
|
3999
|
+
|
4000
|
+
if (cBlockSize > remainingSize) return ERROR(srcSize_wrong);
|
4001
|
+
|
4002
|
+
ip += cBlockSize;
|
4003
|
+
remainingSize -= cBlockSize;
|
4004
|
+
}
|
4005
|
+
|
4006
|
+
return ip - (const BYTE*)src;
|
4007
|
+
}
|
3971
4008
|
|
3972
4009
|
/*_******************************
|
3973
4010
|
* Streaming Decompression API
|
@@ -4448,7 +4485,7 @@ size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* zbd,
|
|
4448
4485
|
zbd->inBuff = (char*)zbd->customMem.customAlloc(zbd->customMem.opaque, blockSize);
|
4449
4486
|
if (zbd->inBuff == NULL) return ERROR(memory_allocation);
|
4450
4487
|
}
|
4451
|
-
{ size_t const neededOutSize = zbd->fParams.windowSize + blockSize;
|
4488
|
+
{ size_t const neededOutSize = zbd->fParams.windowSize + blockSize + WILDCOPY_OVERLENGTH * 2;
|
4452
4489
|
if (zbd->outBuffSize < neededOutSize) {
|
4453
4490
|
zbd->customMem.customFree(zbd->customMem.opaque, zbd->outBuff);
|
4454
4491
|
zbd->outBuffSize = neededOutSize;
|
@@ -4501,7 +4538,8 @@ size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* zbd,
|
|
4501
4538
|
if (!decodedSize && !isSkipFrame) { zbd->stage = ZBUFFds_read; break; } /* this was just a header */
|
4502
4539
|
zbd->outEnd = zbd->outStart + decodedSize;
|
4503
4540
|
zbd->stage = ZBUFFds_flush;
|
4504
|
-
|
4541
|
+
/* break; */
|
4542
|
+
/* pass-through */
|
4505
4543
|
} }
|
4506
4544
|
|
4507
4545
|
case ZBUFFds_flush:
|
@@ -48,6 +48,14 @@ unsigned long long ZSTDv07_getDecompressedSize(const void* src, size_t srcSize);
|
|
48
48
|
ZSTDLIBv07_API size_t ZSTDv07_decompress( void* dst, size_t dstCapacity,
|
49
49
|
const void* src, size_t compressedSize);
|
50
50
|
|
51
|
+
/**
|
52
|
+
ZSTDv07_getFrameSrcSize() : get the source length of a ZSTD frame
|
53
|
+
compressedSize : The size of the 'src' buffer, at least as large as the frame pointed to by 'src'
|
54
|
+
return : the number of bytes that would be read to decompress this frame
|
55
|
+
or an errorCode if it fails (which can be tested using ZSTDv07_isError())
|
56
|
+
*/
|
57
|
+
size_t ZSTDv07_findFrameCompressedSize(const void* src, size_t compressedSize);
|
58
|
+
|
51
59
|
/*====== Helper functions ======*/
|
52
60
|
ZSTDLIBv07_API unsigned ZSTDv07_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
53
61
|
ZSTDLIBv07_API const char* ZSTDv07_getErrorName(size_t code); /*!< provides readable string from an error code */
|
data/ext/zstdruby/libzstd/zstd.h
CHANGED
@@ -39,7 +39,7 @@ extern "C" {
|
|
39
39
|
zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios
|
40
40
|
at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and
|
41
41
|
decompression functions. The library supports compression levels from 1 up to ZSTD_maxCLevel() which is 22.
|
42
|
-
Levels >= 20,
|
42
|
+
Levels >= 20, labeled `--ultra`, should be used with caution, as they require more memory.
|
43
43
|
Compression can be done in:
|
44
44
|
- a single step (described as Simple API)
|
45
45
|
- a single step, reusing a context (described as Explicit memory management)
|
@@ -56,7 +56,7 @@ extern "C" {
|
|
56
56
|
/*------ Version ------*/
|
57
57
|
#define ZSTD_VERSION_MAJOR 1
|
58
58
|
#define ZSTD_VERSION_MINOR 1
|
59
|
-
#define ZSTD_VERSION_RELEASE
|
59
|
+
#define ZSTD_VERSION_RELEASE 4
|
60
60
|
|
61
61
|
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
|
62
62
|
#define ZSTD_QUOTE(str) #str
|
@@ -80,7 +80,7 @@ ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
|
|
80
80
|
int compressionLevel);
|
81
81
|
|
82
82
|
/*! ZSTD_decompress() :
|
83
|
-
`compressedSize` : must be the _exact_ size of
|
83
|
+
`compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
|
84
84
|
`dstCapacity` is an upper bound of originalSize.
|
85
85
|
If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
|
86
86
|
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
@@ -89,6 +89,15 @@ ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
|
|
89
89
|
const void* src, size_t compressedSize);
|
90
90
|
|
91
91
|
/*! ZSTD_getDecompressedSize() :
|
92
|
+
* NOTE: This function is planned to be obsolete, in favour of ZSTD_getFrameContentSize.
|
93
|
+
* ZSTD_getFrameContentSize functions the same way, returning the decompressed size of a single
|
94
|
+
* frame, but distinguishes empty frames from frames with an unknown size, or errors.
|
95
|
+
*
|
96
|
+
* Additionally, ZSTD_findDecompressedSize can be used instead. It can handle multiple
|
97
|
+
* concatenated frames in one buffer, and so is more general.
|
98
|
+
* As a result however, it requires more computation and entire frames to be passed to it,
|
99
|
+
* as opposed to ZSTD_getFrameContentSize which requires only a single frame's header.
|
100
|
+
*
|
92
101
|
* 'src' is the start of a zstd compressed frame.
|
93
102
|
* @return : content size to be decompressed, as a 64-bits value _if known_, 0 otherwise.
|
94
103
|
* note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
|
@@ -130,7 +139,11 @@ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
|
|
130
139
|
Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
|
131
140
|
ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel);
|
132
141
|
|
133
|
-
/*= Decompression context
|
142
|
+
/*= Decompression context
|
143
|
+
* When decompressing many times,
|
144
|
+
* it is recommended to allocate a context just once, and re-use it for each successive compression operation.
|
145
|
+
* This will make workload friendlier for system's memory.
|
146
|
+
* Use one context per thread for parallel execution in multi-threaded environments. */
|
134
147
|
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
135
148
|
ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
|
136
149
|
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
|
@@ -268,9 +281,11 @@ typedef struct ZSTD_outBuffer_s {
|
|
268
281
|
* *******************************************************************/
|
269
282
|
|
270
283
|
typedef struct ZSTD_CStream_s ZSTD_CStream;
|
284
|
+
/*===== ZSTD_CStream management functions =====*/
|
271
285
|
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
|
272
286
|
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
|
273
287
|
|
288
|
+
/*===== Streaming compression functions =====*/
|
274
289
|
ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
|
275
290
|
ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
|
276
291
|
ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
|
@@ -304,9 +319,11 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
|
|
304
319
|
* *******************************************************************************/
|
305
320
|
|
306
321
|
typedef struct ZSTD_DStream_s ZSTD_DStream;
|
322
|
+
/*===== ZSTD_DStream management functions =====*/
|
307
323
|
ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
|
308
324
|
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
|
309
325
|
|
326
|
+
/*===== Streaming decompression functions =====*/
|
310
327
|
ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
|
311
328
|
ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
|
312
329
|
|
@@ -331,9 +348,12 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
|
|
331
348
|
#define ZSTD_MAGICNUMBER 0xFD2FB528 /* >= v0.8.0 */
|
332
349
|
#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U
|
333
350
|
|
334
|
-
#define
|
351
|
+
#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
|
352
|
+
#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
|
353
|
+
|
354
|
+
#define ZSTD_WINDOWLOG_MAX_32 27
|
335
355
|
#define ZSTD_WINDOWLOG_MAX_64 27
|
336
|
-
#define ZSTD_WINDOWLOG_MAX ((
|
356
|
+
#define ZSTD_WINDOWLOG_MAX ((unsigned)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
|
337
357
|
#define ZSTD_WINDOWLOG_MIN 10
|
338
358
|
#define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX
|
339
359
|
#define ZSTD_HASHLOG_MIN 6
|
@@ -384,6 +404,54 @@ typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
|
|
384
404
|
typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
|
385
405
|
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
|
386
406
|
|
407
|
+
/***************************************
|
408
|
+
* Compressed size functions
|
409
|
+
***************************************/
|
410
|
+
|
411
|
+
/*! ZSTD_findFrameCompressedSize() :
|
412
|
+
* `src` should point to the start of a ZSTD encoded frame or skippable frame
|
413
|
+
* `srcSize` must be at least as large as the frame
|
414
|
+
* @return : the compressed size of the frame pointed to by `src`, suitable to pass to
|
415
|
+
* `ZSTD_decompress` or similar, or an error code if given invalid input. */
|
416
|
+
ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
|
417
|
+
|
418
|
+
/***************************************
|
419
|
+
* Decompressed size functions
|
420
|
+
***************************************/
|
421
|
+
/*! ZSTD_getFrameContentSize() :
|
422
|
+
* `src` should point to the start of a ZSTD encoded frame
|
423
|
+
* `srcSize` must be at least as large as the frame header. A value greater than or equal
|
424
|
+
* to `ZSTD_frameHeaderSize_max` is guaranteed to be large enough in all cases.
|
425
|
+
* @return : decompressed size of the frame pointed to be `src` if known, otherwise
|
426
|
+
* - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
|
427
|
+
* - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */
|
428
|
+
ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
|
429
|
+
|
430
|
+
/*! ZSTD_findDecompressedSize() :
|
431
|
+
* `src` should point the start of a series of ZSTD encoded and/or skippable frames
|
432
|
+
* `srcSize` must be the _exact_ size of this series
|
433
|
+
* (i.e. there should be a frame boundary exactly `srcSize` bytes after `src`)
|
434
|
+
* @return : the decompressed size of all data in the contained frames, as a 64-bit value _if known_
|
435
|
+
* - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
|
436
|
+
* - if an error occurred: ZSTD_CONTENTSIZE_ERROR
|
437
|
+
*
|
438
|
+
* note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
|
439
|
+
* When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
|
440
|
+
* In which case, it's necessary to use streaming mode to decompress data.
|
441
|
+
* Optionally, application can still use ZSTD_decompress() while relying on implied limits.
|
442
|
+
* (For example, data may be necessarily cut into blocks <= 16 KB).
|
443
|
+
* note 2 : decompressed size is always present when compression is done with ZSTD_compress()
|
444
|
+
* note 3 : decompressed size can be very large (64-bits value),
|
445
|
+
* potentially larger than what local system can handle as a single memory segment.
|
446
|
+
* In which case, it's necessary to use streaming mode to decompress data.
|
447
|
+
* note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
|
448
|
+
* Always ensure result fits within application's authorized limits.
|
449
|
+
* Each application can set its own limits.
|
450
|
+
* note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
|
451
|
+
* read each contained frame header. This is efficient as most of the data is skipped,
|
452
|
+
* however it does mean that all frame data must be present and valid. */
|
453
|
+
ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
|
454
|
+
|
387
455
|
|
388
456
|
/***************************************
|
389
457
|
* Advanced compression functions
|
@@ -402,7 +470,8 @@ ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
|
|
402
470
|
ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
|
403
471
|
|
404
472
|
typedef enum {
|
405
|
-
ZSTD_p_forceWindow /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0)*/
|
473
|
+
ZSTD_p_forceWindow, /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0) */
|
474
|
+
ZSTD_p_forceRawDict /* Force loading dictionary in "content-only" mode (no header analysis) */
|
406
475
|
} ZSTD_CCtxParameter;
|
407
476
|
/*! ZSTD_setCCtxParameter() :
|
408
477
|
* Set advanced parameters, selected through enum ZSTD_CCtxParameter
|
@@ -479,6 +548,8 @@ ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
|
|
479
548
|
* It is important that dictBuffer outlives DDict, it must remain read accessible throughout the lifetime of DDict */
|
480
549
|
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
|
481
550
|
|
551
|
+
/*! ZSTD_createDDict_advanced() :
|
552
|
+
* Create a ZSTD_DDict using external alloc and free, optionally by reference */
|
482
553
|
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
|
483
554
|
unsigned byReference, ZSTD_customMem customMem);
|
484
555
|
|
@@ -517,12 +588,12 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
517
588
|
|
518
589
|
/*===== Advanced Streaming compression functions =====*/
|
519
590
|
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
|
520
|
-
ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct */
|
591
|
+
ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
|
521
592
|
ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
|
522
593
|
ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
|
523
|
-
ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be
|
594
|
+
ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
|
524
595
|
ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
|
525
|
-
ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before */
|
596
|
+
ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before. note: pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
|
526
597
|
ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
|
527
598
|
|
528
599
|
|
@@ -578,9 +649,9 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
|
|
578
649
|
/*===== Buffer-less streaming compression functions =====*/
|
579
650
|
ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
580
651
|
ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
581
|
-
ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
582
|
-
ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize);
|
583
|
-
ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize);
|
652
|
+
ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
|
653
|
+
ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize can be 0, indicating unknown size. if it is non-zero, it must be accurate. for 0 size frames, use compressBegin_advanced */
|
654
|
+
ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize can be 0, indicating unknown size. if it is non-zero, it must be accurate. for 0 size frames, use compressBegin_advanced */
|
584
655
|
ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
585
656
|
ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
586
657
|
|
@@ -640,6 +711,9 @@ ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapaci
|
|
640
711
|
c) Frame Content - any content (User Data) of length equal to Frame Size
|
641
712
|
For skippable frames ZSTD_decompressContinue() always returns 0.
|
642
713
|
For skippable frames ZSTD_getFrameParams() returns fparamsPtr->windowLog==0 what means that a frame is skippable.
|
714
|
+
Note : If fparamsPtr->frameContentSize==0, it is ambiguous: the frame might actually be a Zstd encoded frame with no content.
|
715
|
+
For purposes of decompression, it is valid in both cases to skip the frame using
|
716
|
+
ZSTD_findFrameCompressedSize to find its size in bytes.
|
643
717
|
It also returns Frame Size as fparamsPtr->frameContentSize.
|
644
718
|
*/
|
645
719
|
|
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.1.
|
4
|
+
version: 1.1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|