zstd-ruby 1.1.4.0 → 1.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +1 -1
  4. data/ext/zstdruby/libzstd/Makefile +11 -1
  5. data/ext/zstdruby/libzstd/README.md +8 -0
  6. data/ext/zstdruby/libzstd/common/bitstream.h +56 -27
  7. data/ext/zstdruby/libzstd/common/error_private.c +2 -1
  8. data/ext/zstdruby/libzstd/common/fse.h +7 -3
  9. data/ext/zstdruby/libzstd/common/huf.h +42 -19
  10. data/ext/zstdruby/libzstd/common/mem.h +2 -3
  11. data/ext/zstdruby/libzstd/common/zstd_errors.h +1 -0
  12. data/ext/zstdruby/libzstd/common/zstd_internal.h +3 -2
  13. data/ext/zstdruby/libzstd/compress/fse_compress.c +10 -10
  14. data/ext/zstdruby/libzstd/compress/zstd_compress.c +455 -244
  15. data/ext/zstdruby/libzstd/compress/zstd_opt.h +6 -4
  16. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +40 -28
  17. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +115 -219
  18. data/ext/zstdruby/libzstd/dictBuilder/cover.c +34 -13
  19. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +65 -43
  20. data/ext/zstdruby/libzstd/dictBuilder/zdict.h +7 -7
  21. data/ext/zstdruby/libzstd/dll/example/README.md +5 -5
  22. data/ext/zstdruby/libzstd/dll/example/build_package.bat +1 -0
  23. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +1 -1
  24. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +21 -21
  25. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +20 -20
  26. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +4 -4
  27. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +2 -2
  28. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +2 -2
  29. data/ext/zstdruby/libzstd/zstd.h +88 -68
  30. data/lib/zstd-ruby/version.rb +1 -1
  31. metadata +3 -3
@@ -477,8 +477,8 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
477
477
 
478
478
  MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
479
479
  {
480
- if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
481
- return BIT_DStream_overflow;
480
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
481
+ return BIT_DStream_overflow;
482
482
 
483
483
  if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer))
484
484
  {
@@ -1335,8 +1335,8 @@ static size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsi
1335
1335
  else
1336
1336
  {
1337
1337
  bitCount -= (int)(8 * (iend - 4 - ip));
1338
- ip = iend - 4;
1339
- }
1338
+ ip = iend - 4;
1339
+ }
1340
1340
  bitStream = MEM_readLE32(ip) >> (bitCount & 31);
1341
1341
  }
1342
1342
  }
@@ -2037,7 +2037,7 @@ static size_t HUF_readDTableX4 (U32* DTable, const void* src, size_t srcSize)
2037
2037
  rankStart[0] = 0; /* forget 0w symbols; this is beginning of weight(1) */
2038
2038
  }
2039
2039
 
2040
- /* Build rankVal */
2040
+ /* Build rankVal */
2041
2041
  {
2042
2042
  const U32 minBits = tableLog+1 - maxW;
2043
2043
  U32 nextRankVal = 0;
@@ -2589,14 +2589,14 @@ static size_t ZSTD_decodeLiteralsBlock(void* ctx,
2589
2589
  const size_t litSize = (MEM_readLE32(istart) & 0xFFFFFF) >> 2; /* no buffer issue : srcSize >= MIN_CBLOCK_SIZE */
2590
2590
  if (litSize > srcSize-11) /* risk of reading too far with wildcopy */
2591
2591
  {
2592
- if (litSize > srcSize-3) return ERROR(corruption_detected);
2593
- memcpy(dctx->litBuffer, istart, litSize);
2594
- dctx->litPtr = dctx->litBuffer;
2595
- dctx->litSize = litSize;
2596
- memset(dctx->litBuffer + dctx->litSize, 0, 8);
2597
- return litSize+3;
2598
- }
2599
- /* direct reference into compressed stream */
2592
+ if (litSize > srcSize-3) return ERROR(corruption_detected);
2593
+ memcpy(dctx->litBuffer, istart, litSize);
2594
+ dctx->litPtr = dctx->litBuffer;
2595
+ dctx->litSize = litSize;
2596
+ memset(dctx->litBuffer + dctx->litSize, 0, 8);
2597
+ return litSize+3;
2598
+ }
2599
+ /* direct reference into compressed stream */
2600
2600
  dctx->litPtr = istart+3;
2601
2601
  dctx->litSize = litSize;
2602
2602
  return litSize+3;
@@ -3156,13 +3156,13 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
3156
3156
 
3157
3157
  unsigned ZSTDv03_isError(size_t code)
3158
3158
  {
3159
- return ZSTD_isError(code);
3159
+ return ZSTD_isError(code);
3160
3160
  }
3161
3161
 
3162
3162
  size_t ZSTDv03_decompress( void* dst, size_t maxOriginalSize,
3163
3163
  const void* src, size_t compressedSize)
3164
3164
  {
3165
- return ZSTD_decompress(dst, maxOriginalSize, src, compressedSize);
3165
+ return ZSTD_decompress(dst, maxOriginalSize, src, compressedSize);
3166
3166
  }
3167
3167
 
3168
3168
  size_t ZSTDv03_findFrameCompressedSize(const void* src, size_t srcSize)
@@ -3172,25 +3172,25 @@ size_t ZSTDv03_findFrameCompressedSize(const void* src, size_t srcSize)
3172
3172
 
3173
3173
  ZSTDv03_Dctx* ZSTDv03_createDCtx(void)
3174
3174
  {
3175
- return (ZSTDv03_Dctx*)ZSTD_createDCtx();
3175
+ return (ZSTDv03_Dctx*)ZSTD_createDCtx();
3176
3176
  }
3177
3177
 
3178
3178
  size_t ZSTDv03_freeDCtx(ZSTDv03_Dctx* dctx)
3179
3179
  {
3180
- return ZSTD_freeDCtx((ZSTD_DCtx*)dctx);
3180
+ return ZSTD_freeDCtx((ZSTD_DCtx*)dctx);
3181
3181
  }
3182
3182
 
3183
3183
  size_t ZSTDv03_resetDCtx(ZSTDv03_Dctx* dctx)
3184
3184
  {
3185
- return ZSTD_resetDCtx((ZSTD_DCtx*)dctx);
3185
+ return ZSTD_resetDCtx((ZSTD_DCtx*)dctx);
3186
3186
  }
3187
3187
 
3188
3188
  size_t ZSTDv03_nextSrcSizeToDecompress(ZSTDv03_Dctx* dctx)
3189
3189
  {
3190
- return ZSTD_nextSrcSizeToDecompress((ZSTD_DCtx*)dctx);
3190
+ return ZSTD_nextSrcSizeToDecompress((ZSTD_DCtx*)dctx);
3191
3191
  }
3192
3192
 
3193
3193
  size_t ZSTDv03_decompressContinue(ZSTDv03_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
3194
3194
  {
3195
- return ZSTD_decompressContinue((ZSTD_DCtx*)dctx, dst, maxDstSize, src, srcSize);
3195
+ return ZSTD_decompressContinue((ZSTD_DCtx*)dctx, dst, maxDstSize, src, srcSize);
3196
3196
  }
@@ -882,8 +882,8 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
882
882
 
883
883
  MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
884
884
  {
885
- if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
886
- return BIT_DStream_overflow;
885
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
886
+ return BIT_DStream_overflow;
887
887
 
888
888
  if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer))
889
889
  {
@@ -1451,8 +1451,8 @@ static size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsi
1451
1451
  else
1452
1452
  {
1453
1453
  bitCount -= (int)(8 * (iend - 4 - ip));
1454
- ip = iend - 4;
1455
- }
1454
+ ip = iend - 4;
1455
+ }
1456
1456
  bitStream = MEM_readLE32(ip) >> (bitCount & 31);
1457
1457
  }
1458
1458
  }
@@ -884,8 +884,8 @@ MEM_STATIC size_t BITv05_readBitsFast(BITv05_DStream_t* bitD, U32 nbBits)
884
884
 
885
885
  MEM_STATIC BITv05_DStream_status BITv05_reloadDStream(BITv05_DStream_t* bitD)
886
886
  {
887
- if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
888
- return BITv05_DStream_overflow;
887
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
888
+ return BITv05_DStream_overflow;
889
889
 
890
890
  if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) {
891
891
  bitD->ptr -= bitD->bitsConsumed >> 3;
@@ -982,8 +982,8 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, U32 nbBits)
982
982
  if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */
983
983
  MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD)
984
984
  {
985
- if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
986
- return BITv06_DStream_overflow;
985
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
986
+ return BITv06_DStream_overflow;
987
987
 
988
988
  if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) {
989
989
  bitD->ptr -= bitD->bitsConsumed >> 3;
@@ -55,8 +55,8 @@ extern "C" {
55
55
 
56
56
  /*------ Version ------*/
57
57
  #define ZSTD_VERSION_MAJOR 1
58
- #define ZSTD_VERSION_MINOR 1
59
- #define ZSTD_VERSION_RELEASE 4
58
+ #define ZSTD_VERSION_MINOR 2
59
+ #define ZSTD_VERSION_RELEASE 0
60
60
 
61
61
  #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
62
62
  #define ZSTD_QUOTE(str) #str
@@ -71,48 +71,48 @@ ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< library version number; to
71
71
  * Simple API
72
72
  ***************************************/
73
73
  /*! ZSTD_compress() :
74
- Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
75
- Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
76
- @return : compressed size written into `dst` (<= `dstCapacity),
77
- or an error code if it fails (which can be tested using ZSTD_isError()). */
74
+ * Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
75
+ * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
76
+ * @return : compressed size written into `dst` (<= `dstCapacity),
77
+ * or an error code if it fails (which can be tested using ZSTD_isError()). */
78
78
  ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
79
79
  const void* src, size_t srcSize,
80
80
  int compressionLevel);
81
81
 
82
82
  /*! ZSTD_decompress() :
83
- `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
84
- `dstCapacity` is an upper bound of originalSize.
85
- If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
86
- @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
87
- or an errorCode if it fails (which can be tested using ZSTD_isError()). */
83
+ * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
84
+ * `dstCapacity` is an upper bound of originalSize.
85
+ * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
86
+ * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
87
+ * or an errorCode if it fails (which can be tested using ZSTD_isError()). */
88
88
  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
- *
101
- * 'src' is the start of a zstd compressed frame.
102
- * @return : content size to be decompressed, as a 64-bits value _if known_, 0 otherwise.
103
- * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
104
- * When `return==0`, data to decompress could be any size.
105
- * In which case, it's necessary to use streaming mode to decompress data.
106
- * Optionally, application can still use ZSTD_decompress() while relying on implied limits.
107
- * (For example, data may be necessarily cut into blocks <= 16 KB).
108
- * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
109
- * note 3 : decompressed size can be very large (64-bits value),
110
- * potentially larger than what local system can handle as a single memory segment.
111
- * In which case, it's necessary to use streaming mode to decompress data.
112
- * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
113
- * Always ensure result fits within application's authorized limits.
114
- * Each application can set its own limits.
115
- * note 5 : when `return==0`, if precise failure cause is needed, use ZSTD_getFrameParams() to know more. */
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
+ *
101
+ * 'src' is the start of a zstd compressed frame.
102
+ * @return : content size to be decompressed, as a 64-bits value _if known_, 0 otherwise.
103
+ * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
104
+ * When `return==0`, data to decompress could be any size.
105
+ * In which case, it's necessary to use streaming mode to decompress data.
106
+ * Optionally, application can still use ZSTD_decompress() while relying on implied limits.
107
+ * (For example, data may be necessarily cut into blocks <= 16 KB).
108
+ * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
109
+ * note 3 : decompressed size can be very large (64-bits value),
110
+ * potentially larger than what local system can handle as a single memory segment.
111
+ * In which case, it's necessary to use streaming mode to decompress data.
112
+ * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
113
+ * Always ensure result fits within application's authorized limits.
114
+ * Each application can set its own limits.
115
+ * note 5 : when `return==0`, if precise failure cause is needed, use ZSTD_getFrameParams() to know more. */
116
116
  ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
117
117
 
118
118
 
@@ -127,29 +127,29 @@ ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readab
127
127
  * Explicit memory management
128
128
  ***************************************/
129
129
  /*= Compression context
130
- * When compressing many times,
131
- * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
132
- * This will make workload friendlier for system's memory.
133
- * Use one context per thread for parallel execution in multi-threaded environments. */
130
+ * When compressing many times,
131
+ * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
132
+ * This will make workload friendlier for system's memory.
133
+ * Use one context per thread for parallel execution in multi-threaded environments. */
134
134
  typedef struct ZSTD_CCtx_s ZSTD_CCtx;
135
135
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
136
136
  ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
137
137
 
138
138
  /*! ZSTD_compressCCtx() :
139
- Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
139
+ * Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
140
140
  ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel);
141
141
 
142
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. */
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. */
147
147
  typedef struct ZSTD_DCtx_s ZSTD_DCtx;
148
148
  ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
149
149
  ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
150
150
 
151
151
  /*! ZSTD_decompressDCtx() :
152
- * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()). */
152
+ * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()). */
153
153
  ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
154
154
 
155
155
 
@@ -194,9 +194,10 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize
194
194
  ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
195
195
 
196
196
  /*! ZSTD_compress_usingCDict() :
197
- * Compression using a digested Dictionary.
198
- * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
199
- * Note that compression level is decided during dictionary creation. */
197
+ * Compression using a digested Dictionary.
198
+ * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
199
+ * Note that compression level is decided during dictionary creation.
200
+ * Frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) */
200
201
  ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
201
202
  void* dst, size_t dstCapacity,
202
203
  const void* src, size_t srcSize,
@@ -487,7 +488,7 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, siz
487
488
  /*! ZSTD_createCDict_advanced() :
488
489
  * Create a ZSTD_CDict using external alloc and free, and customized compression parameters */
489
490
  ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, unsigned byReference,
490
- ZSTD_parameters params, ZSTD_customMem customMem);
491
+ ZSTD_compressionParameters cParams, ZSTD_customMem customMem);
491
492
 
492
493
  /*! ZSTD_sizeof_CDict() :
493
494
  * Gives the amount of memory used by a given ZSTD_sizeof_CDict */
@@ -513,12 +514,19 @@ ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
513
514
  ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
514
515
 
515
516
  /*! ZSTD_compress_advanced() :
516
- * Same as ZSTD_compress_usingDict(), with fine-tune control of each compression parameter */
517
- ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* ctx,
518
- void* dst, size_t dstCapacity,
519
- const void* src, size_t srcSize,
520
- const void* dict,size_t dictSize,
521
- ZSTD_parameters params);
517
+ * Same as ZSTD_compress_usingDict(), with fine-tune control over each compression parameter */
518
+ ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx,
519
+ void* dst, size_t dstCapacity,
520
+ const void* src, size_t srcSize,
521
+ const void* dict,size_t dictSize,
522
+ ZSTD_parameters params);
523
+
524
+ /*! ZSTD_compress_usingCDict_advanced() :
525
+ * Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters */
526
+ ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
527
+ void* dst, size_t dstCapacity,
528
+ const void* src, size_t srcSize,
529
+ const ZSTD_CDict* cdict, ZSTD_frameParameters fParams);
522
530
 
523
531
 
524
532
  /*--- Advanced decompression functions ---*/
@@ -578,7 +586,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
578
586
  * Note : this use case also happens when using a non-conformant dictionary.
579
587
  * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
580
588
  * - This is not a Zstandard frame.
581
- * When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */
589
+ * When identifying the exact failure cause, it's possible to use ZSTD_getFrameParams(), which will provide a more precise error code. */
582
590
  ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
583
591
 
584
592
 
@@ -588,13 +596,22 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
588
596
 
589
597
  /*===== Advanced Streaming compression functions =====*/
590
598
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
599
+ ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); /**< size of CStream is variable, depending primarily on compression level */
591
600
  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 */
592
601
  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 */
593
602
  ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
594
603
  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 */
595
604
  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 */
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 */
597
- ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
605
+ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize, ZSTD_frameParameters fParams); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
606
+
607
+ /*! ZSTD_resetCStream() :
608
+ * start a new compression job, using same parameters from previous job.
609
+ * This is typically useful to skip dictionary loading stage, since it will re-use it in-place..
610
+ * Note that zcs must be init at least once before using ZSTD_resetCStream().
611
+ * pledgedSrcSize==0 means "srcSize unknown".
612
+ * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
613
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
614
+ ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
598
615
 
599
616
 
600
617
  /*===== Advanced Streaming decompression functions =====*/
@@ -650,8 +667,10 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
650
667
  ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
651
668
  ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
652
669
  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 */
670
+ ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
671
+ ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize=0 means null-size */
653
672
  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 */
673
+
655
674
  ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
656
675
  ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
657
676
 
@@ -745,19 +764,20 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
745
764
  - Compressing and decompressing require a context structure
746
765
  + Use ZSTD_createCCtx() and ZSTD_createDCtx()
747
766
  - It is necessary to init context before starting
748
- + compression : ZSTD_compressBegin()
749
- + decompression : ZSTD_decompressBegin()
750
- + variants _usingDict() are also allowed
751
- + copyCCtx() and copyDCtx() work too
752
- - Block size is limited, it must be <= ZSTD_getBlockSizeMax()
753
- + If you need to compress more, cut data into multiple blocks
754
- + Consider using the regular ZSTD_compress() instead, as frame metadata costs become negligible when source size is large.
767
+ + compression : any ZSTD_compressBegin*() variant, including with dictionary
768
+ + decompression : any ZSTD_decompressBegin*() variant, including with dictionary
769
+ + copyCCtx() and copyDCtx() can be used too
770
+ - Block size is limited, it must be <= ZSTD_getBlockSizeMax() <= ZSTD_BLOCKSIZE_ABSOLUTEMAX
771
+ + If input is larger than a block size, it's necessary to split input data into multiple blocks
772
+ + For inputs larger than a single block size, consider using the regular ZSTD_compress() instead.
773
+ Frame metadata is not that costly, and quickly becomes negligible as source size grows larger.
755
774
  - When a block is considered not compressible enough, ZSTD_compressBlock() result will be zero.
756
775
  In which case, nothing is produced into `dst`.
757
776
  + User must test for such outcome and deal directly with uncompressed data
758
777
  + ZSTD_decompressBlock() doesn't accept uncompressed data as input !!!
759
- + In case of multiple successive blocks, decoder must be informed of uncompressed block existence to follow proper history.
760
- Use ZSTD_insertBlock() in such a case.
778
+ + In case of multiple successive blocks, should some of them be uncompressed,
779
+ decoder must be informed of their existence in order to follow proper history.
780
+ Use ZSTD_insertBlock() for such a case.
761
781
  */
762
782
 
763
783
  #define ZSTD_BLOCKSIZE_ABSOLUTEMAX (128 * 1024) /* define, for static allocation */
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "1.1.4.0"
2
+ VERSION = "1.2.0.0"
3
3
  end
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.0
4
+ version: 1.2.0.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-03-18 00:00:00.000000000 Z
11
+ date: 2017-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
- rubygems_version: 2.5.1
176
+ rubygems_version: 2.6.11
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)