zstdlib 0.14.0-x86-mingw32 → 0.15.0-x86-mingw32

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/ext/zstdlib_c/extconf.rb +1 -1
  4. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/bits.h +92 -87
  5. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/bitstream.h +26 -29
  6. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/compiler.h +36 -22
  7. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/cpu.h +1 -1
  8. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/debug.h +0 -9
  9. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/error_private.c +1 -0
  10. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/error_private.h +0 -10
  11. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/fse.h +2 -17
  12. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/fse_decompress.c +2 -0
  13. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/huf.h +0 -9
  14. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/mem.h +7 -11
  15. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/pool.h +0 -9
  16. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/portability_macros.h +22 -9
  17. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/threading.h +0 -8
  18. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/xxhash.h +93 -19
  19. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_deps.h +12 -0
  20. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_internal.h +1 -69
  21. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_trace.h +5 -12
  22. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/hist.c +10 -0
  23. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/hist.h +7 -0
  24. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress.c +1057 -367
  25. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_internal.h +227 -125
  26. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_literals.c +1 -1
  27. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_sequences.c +7 -7
  28. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_sequences.h +7 -6
  29. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_superblock.c +17 -17
  30. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_cwksp.h +41 -24
  31. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_double_fast.c +58 -50
  32. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_double_fast.h +4 -12
  33. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_fast.c +91 -74
  34. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_fast.h +4 -12
  35. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_lazy.c +64 -64
  36. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_lazy.h +30 -39
  37. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm.c +48 -33
  38. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm.h +6 -14
  39. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_opt.c +55 -51
  40. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_opt.h +8 -16
  41. data/ext/zstdlib_c/zstd-1.5.7/lib/compress/zstd_preSplit.c +238 -0
  42. data/ext/zstdlib_c/zstd-1.5.7/lib/compress/zstd_preSplit.h +33 -0
  43. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstdmt_compress.c +134 -93
  44. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstdmt_compress.h +4 -15
  45. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/huf_decompress_amd64.S +10 -3
  46. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress.c +14 -11
  47. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_block.c +6 -12
  48. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_internal.h +5 -5
  49. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zdict.h +15 -8
  50. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zstd.h +241 -132
  51. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zstd_errors.h +1 -8
  52. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzwrite.c +2 -1
  53. data/lib/2.4/zstdlib_c.so +0 -0
  54. data/lib/2.5/zstdlib_c.so +0 -0
  55. data/lib/2.6/zstdlib_c.so +0 -0
  56. data/lib/2.7/zstdlib_c.so +0 -0
  57. data/lib/3.0/zstdlib_c.so +0 -0
  58. data/lib/3.1/zstdlib_c.so +0 -0
  59. data/lib/3.2/zstdlib_c.so +0 -0
  60. data/lib/3.3/zstdlib_c.so +0 -0
  61. data/lib/3.4/zstdlib_c.so +0 -0
  62. metadata +75 -73
  63. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/allocations.h +0 -0
  64. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/debug.c +0 -0
  65. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/entropy_common.c +0 -0
  66. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/pool.c +0 -0
  67. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/threading.c +0 -0
  68. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/xxhash.c +0 -0
  69. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_common.c +0 -0
  70. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/clevels.h +0 -0
  71. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/fse_compress.c +0 -0
  72. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/huf_compress.c +0 -0
  73. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_literals.h +0 -0
  74. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_superblock.h +0 -0
  75. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm_geartab.h +0 -0
  76. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/huf_decompress.c +0 -0
  77. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_ddict.c +0 -0
  78. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_ddict.h +0 -0
  79. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_block.h +0 -0
  80. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzclose.c +0 -0
  81. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzcompatibility.h +0 -0
  82. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzguts.h +0 -0
  83. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzlib.c +0 -0
  84. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzread.c +0 -0
  85. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/zstd_zlibwrapper.c +0 -0
  86. data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/zstd_zlibwrapper.h +5 -5
@@ -7,17 +7,22 @@
7
7
  * in the COPYING file in the root directory of this source tree).
8
8
  * You may select, at your option, one of the above-listed licenses.
9
9
  */
10
- #if defined (__cplusplus)
11
- extern "C" {
12
- #endif
13
10
 
14
11
  #ifndef ZSTD_H_235446
15
12
  #define ZSTD_H_235446
16
13
 
14
+
17
15
  /* ====== Dependencies ======*/
18
- #include <limits.h> /* INT_MAX */
19
16
  #include <stddef.h> /* size_t */
20
17
 
18
+ #include "zstd_errors.h" /* list of errors */
19
+ #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
20
+ #include <limits.h> /* INT_MAX */
21
+ #endif /* ZSTD_STATIC_LINKING_ONLY */
22
+
23
+ #if defined (__cplusplus)
24
+ extern "C" {
25
+ #endif
21
26
 
22
27
  /* ===== ZSTDLIB_API : control library symbols visibility ===== */
23
28
  #ifndef ZSTDLIB_VISIBLE
@@ -57,7 +62,7 @@ extern "C" {
57
62
  #else
58
63
  # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
59
64
  # define ZSTD_DEPRECATED(message) [[deprecated(message)]]
60
- # elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
65
+ # elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__) || defined(__IAR_SYSTEMS_ICC__)
61
66
  # define ZSTD_DEPRECATED(message) __attribute__((deprecated(message)))
62
67
  # elif defined(__GNUC__) && (__GNUC__ >= 3)
63
68
  # define ZSTD_DEPRECATED(message) __attribute__((deprecated))
@@ -106,7 +111,7 @@ extern "C" {
106
111
  /*------ Version ------*/
107
112
  #define ZSTD_VERSION_MAJOR 1
108
113
  #define ZSTD_VERSION_MINOR 5
109
- #define ZSTD_VERSION_RELEASE 6
114
+ #define ZSTD_VERSION_RELEASE 7
110
115
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
111
116
 
112
117
  /*! ZSTD_versionNumber() :
@@ -144,7 +149,7 @@ ZSTDLIB_API const char* ZSTD_versionString(void);
144
149
 
145
150
 
146
151
  /***************************************
147
- * Simple API
152
+ * Simple Core API
148
153
  ***************************************/
149
154
  /*! ZSTD_compress() :
150
155
  * Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
@@ -157,68 +162,80 @@ ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
157
162
  int compressionLevel);
158
163
 
159
164
  /*! ZSTD_decompress() :
160
- * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
161
- * `dstCapacity` is an upper bound of originalSize to regenerate.
162
- * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
163
- * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
164
- * or an errorCode if it fails (which can be tested using ZSTD_isError()). */
165
+ * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
166
+ * Multiple compressed frames can be decompressed at once with this method.
167
+ * The result will be the concatenation of all decompressed frames, back to back.
168
+ * `dstCapacity` is an upper bound of originalSize to regenerate.
169
+ * First frame's decompressed size can be extracted using ZSTD_getFrameContentSize().
170
+ * If maximum upper bound isn't known, prefer using streaming mode to decompress data.
171
+ * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
172
+ * or an errorCode if it fails (which can be tested using ZSTD_isError()). */
165
173
  ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
166
174
  const void* src, size_t compressedSize);
167
175
 
176
+
177
+ /*====== Decompression helper functions ======*/
178
+
168
179
  /*! ZSTD_getFrameContentSize() : requires v1.3.0+
169
- * `src` should point to the start of a ZSTD encoded frame.
170
- * `srcSize` must be at least as large as the frame header.
171
- * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
172
- * @return : - decompressed size of `src` frame content, if known
173
- * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
174
- * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
175
- * note 1 : a 0 return value means the frame is valid but "empty".
176
- * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
177
- * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
178
- * In which case, it's necessary to use streaming mode to decompress data.
179
- * Optionally, application can rely on some implicit limit,
180
- * as ZSTD_decompress() only needs an upper bound of decompressed size.
181
- * (For example, data could be necessarily cut into blocks <= 16 KB).
182
- * note 3 : decompressed size is always present when compression is completed using single-pass functions,
183
- * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
184
- * note 4 : decompressed size can be very large (64-bits value),
185
- * potentially larger than what local system can handle as a single memory segment.
186
- * In which case, it's necessary to use streaming mode to decompress data.
187
- * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
188
- * Always ensure return value fits within application's authorized limits.
189
- * Each application can set its own limits.
190
- * note 6 : This function replaces ZSTD_getDecompressedSize() */
180
+ * `src` should point to the start of a ZSTD encoded frame.
181
+ * `srcSize` must be at least as large as the frame header.
182
+ * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
183
+ * @return : - decompressed size of `src` frame content, if known
184
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
185
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
186
+ * note 1 : a 0 return value means the frame is valid but "empty".
187
+ * When invoking this method on a skippable frame, it will return 0.
188
+ * note 2 : decompressed size is an optional field, it may not be present (typically in streaming mode).
189
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
190
+ * In which case, it's necessary to use streaming mode to decompress data.
191
+ * Optionally, application can rely on some implicit limit,
192
+ * as ZSTD_decompress() only needs an upper bound of decompressed size.
193
+ * (For example, data could be necessarily cut into blocks <= 16 KB).
194
+ * note 3 : decompressed size is always present when compression is completed using single-pass functions,
195
+ * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
196
+ * note 4 : decompressed size can be very large (64-bits value),
197
+ * potentially larger than what local system can handle as a single memory segment.
198
+ * In which case, it's necessary to use streaming mode to decompress data.
199
+ * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
200
+ * Always ensure return value fits within application's authorized limits.
201
+ * Each application can set its own limits.
202
+ * note 6 : This function replaces ZSTD_getDecompressedSize() */
191
203
  #define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
192
204
  #define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
193
205
  ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
194
206
 
195
- /*! ZSTD_getDecompressedSize() :
196
- * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
207
+ /*! ZSTD_getDecompressedSize() (obsolete):
208
+ * This function is now obsolete, in favor of ZSTD_getFrameContentSize().
197
209
  * Both functions work the same way, but ZSTD_getDecompressedSize() blends
198
210
  * "empty", "unknown" and "error" results to the same return value (0),
199
211
  * while ZSTD_getFrameContentSize() gives them separate return values.
200
212
  * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
201
213
  ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
202
- ZSTDLIB_API
203
- unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
214
+ ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
204
215
 
205
216
  /*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+
206
217
  * `src` should point to the start of a ZSTD frame or skippable frame.
207
218
  * `srcSize` must be >= first frame size
208
219
  * @return : the compressed size of the first frame starting at `src`,
209
220
  * suitable to pass as `srcSize` to `ZSTD_decompress` or similar,
210
- * or an error code if input is invalid */
221
+ * or an error code if input is invalid
222
+ * Note 1: this method is called _find*() because it's not enough to read the header,
223
+ * it may have to scan through the frame's content, to reach its end.
224
+ * Note 2: this method also works with Skippable Frames. In which case,
225
+ * it returns the size of the complete skippable frame,
226
+ * which is always equal to its content size + 8 bytes for headers. */
211
227
  ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
212
228
 
213
229
 
214
- /*====== Helper functions ======*/
215
- /* ZSTD_compressBound() :
230
+ /*====== Compression helper functions ======*/
231
+
232
+ /*! ZSTD_compressBound() :
216
233
  * maximum compressed size in worst case single-pass scenario.
217
- * When invoking `ZSTD_compress()` or any other one-pass compression function,
234
+ * When invoking `ZSTD_compress()`, or any other one-pass compression function,
218
235
  * it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize)
219
236
  * as it eliminates one potential failure scenario,
220
237
  * aka not enough room in dst buffer to write the compressed frame.
221
- * Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
238
+ * Note : ZSTD_compressBound() itself can fail, if @srcSize >= ZSTD_MAX_INPUT_SIZE .
222
239
  * In which case, ZSTD_compressBound() will return an error code
223
240
  * which can be tested using ZSTD_isError().
224
241
  *
@@ -226,21 +243,25 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
226
243
  * same as ZSTD_compressBound(), but as a macro.
227
244
  * It can be used to produce constants, which can be useful for static allocation,
228
245
  * for example to size a static array on stack.
229
- * Will produce constant value 0 if srcSize too large.
246
+ * Will produce constant value 0 if srcSize is too large.
230
247
  */
231
248
  #define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
232
249
  #define ZSTD_COMPRESSBOUND(srcSize) (((size_t)(srcSize) >= ZSTD_MAX_INPUT_SIZE) ? 0 : (srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
233
250
  ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
251
+
252
+
253
+ /*====== Error helper functions ======*/
234
254
  /* ZSTD_isError() :
235
255
  * Most ZSTD_* functions returning a size_t value can be tested for error,
236
256
  * using ZSTD_isError().
237
257
  * @return 1 if error, 0 otherwise
238
258
  */
239
- ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
240
- ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
241
- ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
242
- ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
243
- ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
259
+ ZSTDLIB_API unsigned ZSTD_isError(size_t result); /*!< tells if a `size_t` function result is an error code */
260
+ ZSTDLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); /* convert a result into an error code, which can be compared to error enum list */
261
+ ZSTDLIB_API const char* ZSTD_getErrorName(size_t result); /*!< provides readable string from a function result */
262
+ ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
263
+ ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
264
+ ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
244
265
 
245
266
 
246
267
  /***************************************
@@ -248,17 +269,17 @@ ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compres
248
269
  ***************************************/
249
270
  /*= Compression context
250
271
  * When compressing many times,
251
- * it is recommended to allocate a context just once,
272
+ * it is recommended to allocate a compression context just once,
252
273
  * and reuse it for each successive compression operation.
253
- * This will make workload friendlier for system's memory.
274
+ * This will make the workload easier for system's memory.
254
275
  * Note : re-using context is just a speed / resource optimization.
255
276
  * It doesn't change the compression ratio, which remains identical.
256
- * Note 2 : In multi-threaded environments,
257
- * use one different context per thread for parallel execution.
277
+ * Note 2: For parallel execution in multi-threaded environments,
278
+ * use one different context per thread .
258
279
  */
259
280
  typedef struct ZSTD_CCtx_s ZSTD_CCtx;
260
281
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
261
- ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
282
+ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* compatible with NULL pointer */
262
283
 
263
284
  /*! ZSTD_compressCCtx() :
264
285
  * Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
@@ -266,7 +287,7 @@ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer *
266
287
  * this function compresses at the requested compression level,
267
288
  * __ignoring any other advanced parameter__ .
268
289
  * If any advanced parameter was set using the advanced API,
269
- * they will all be reset. Only `compressionLevel` remains.
290
+ * they will all be reset. Only @compressionLevel remains.
270
291
  */
271
292
  ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
272
293
  void* dst, size_t dstCapacity,
@@ -392,7 +413,7 @@ typedef enum {
392
413
  * Special: value 0 means "use default strategy". */
393
414
 
394
415
  ZSTD_c_targetCBlockSize=130, /* v1.5.6+
395
- * Attempts to fit compressed block size into approximatively targetCBlockSize.
416
+ * Attempts to fit compressed block size into approximately targetCBlockSize.
396
417
  * Bound by ZSTD_TARGETCBLOCKSIZE_MIN and ZSTD_TARGETCBLOCKSIZE_MAX.
397
418
  * Note that it's not a guarantee, just a convergence target (default:0).
398
419
  * No target when targetCBlockSize == 0.
@@ -488,7 +509,8 @@ typedef enum {
488
509
  * ZSTD_c_stableOutBuffer
489
510
  * ZSTD_c_blockDelimiters
490
511
  * ZSTD_c_validateSequences
491
- * ZSTD_c_useBlockSplitter
512
+ * ZSTD_c_blockSplitterLevel
513
+ * ZSTD_c_splitAfterSequences
492
514
  * ZSTD_c_useRowMatchFinder
493
515
  * ZSTD_c_prefetchCDictTables
494
516
  * ZSTD_c_enableSeqProducerFallback
@@ -515,7 +537,8 @@ typedef enum {
515
537
  ZSTD_c_experimentalParam16=1013,
516
538
  ZSTD_c_experimentalParam17=1014,
517
539
  ZSTD_c_experimentalParam18=1015,
518
- ZSTD_c_experimentalParam19=1016
540
+ ZSTD_c_experimentalParam19=1016,
541
+ ZSTD_c_experimentalParam20=1017
519
542
  } ZSTD_cParameter;
520
543
 
521
544
  typedef struct {
@@ -855,7 +878,7 @@ ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
855
878
  *
856
879
  * A ZSTD_DStream object is required to track streaming operations.
857
880
  * Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
858
- * ZSTD_DStream objects can be reused multiple times.
881
+ * ZSTD_DStream objects can be re-employed multiple times.
859
882
  *
860
883
  * Use ZSTD_initDStream() to start a new decompression operation.
861
884
  * @return : recommended first input size
@@ -865,16 +888,21 @@ ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
865
888
  * The function will update both `pos` fields.
866
889
  * If `input.pos < input.size`, some input has not been consumed.
867
890
  * It's up to the caller to present again remaining data.
891
+ *
868
892
  * The function tries to flush all data decoded immediately, respecting output buffer size.
869
893
  * If `output.pos < output.size`, decoder has flushed everything it could.
870
- * But if `output.pos == output.size`, there might be some data left within internal buffers.,
894
+ *
895
+ * However, when `output.pos == output.size`, it's more difficult to know.
896
+ * If @return > 0, the frame is not complete, meaning
897
+ * either there is still some data left to flush within internal buffers,
898
+ * or there is more input to read to complete the frame (or both).
871
899
  * In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
872
900
  * Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
873
901
  * @return : 0 when a frame is completely decoded and fully flushed,
874
902
  * or an error code, which can be tested using ZSTD_isError(),
875
903
  * or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
876
904
  * the return value is a suggested next input size (just a hint for better latency)
877
- * that will never request more than the remaining frame size.
905
+ * that will never request more than the remaining content of the compressed frame.
878
906
  * *******************************************************************************/
879
907
 
880
908
  typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
@@ -901,9 +929,10 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
901
929
  * Function will update both input and output `pos` fields exposing current state via these fields:
902
930
  * - `input.pos < input.size`, some input remaining and caller should provide remaining input
903
931
  * on the next call.
904
- * - `output.pos < output.size`, decoder finished and flushed all remaining buffers.
905
- * - `output.pos == output.size`, potentially uncflushed data present in the internal buffers,
906
- * call ZSTD_decompressStream() again to flush remaining data to output.
932
+ * - `output.pos < output.size`, decoder flushed internal output buffer.
933
+ * - `output.pos == output.size`, unflushed data potentially present in the internal buffers,
934
+ * check ZSTD_decompressStream() @return value,
935
+ * if > 0, invoke it again to flush remaining data to output.
907
936
  * Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX.
908
937
  *
909
938
  * @return : 0 when a frame is completely decoded and fully flushed,
@@ -1181,6 +1210,10 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
1181
1210
  ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
1182
1211
  ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1183
1212
 
1213
+ #if defined (__cplusplus)
1214
+ }
1215
+ #endif
1216
+
1184
1217
  #endif /* ZSTD_H_235446 */
1185
1218
 
1186
1219
 
@@ -1196,6 +1229,10 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1196
1229
  #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
1197
1230
  #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
1198
1231
 
1232
+ #if defined (__cplusplus)
1233
+ extern "C" {
1234
+ #endif
1235
+
1199
1236
  /* This can be overridden externally to hide static symbols. */
1200
1237
  #ifndef ZSTDLIB_STATIC_API
1201
1238
  # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
@@ -1307,7 +1344,7 @@ typedef struct {
1307
1344
  *
1308
1345
  * Note: This field is optional. ZSTD_generateSequences() will calculate the value of
1309
1346
  * 'rep', but repeat offsets do not necessarily need to be calculated from an external
1310
- * sequence provider's perspective. For example, ZSTD_compressSequences() does not
1347
+ * sequence provider perspective. For example, ZSTD_compressSequences() does not
1311
1348
  * use this 'rep' field at all (as of now).
1312
1349
  */
1313
1350
  } ZSTD_Sequence;
@@ -1412,14 +1449,15 @@ typedef enum {
1412
1449
  } ZSTD_literalCompressionMode_e;
1413
1450
 
1414
1451
  typedef enum {
1415
- /* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final
1416
- * decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
1417
- * or ZSTD_ps_disable allow for a force enable/disable the feature.
1452
+ /* Note: This enum controls features which are conditionally beneficial.
1453
+ * Zstd can take a decision on whether or not to enable the feature (ZSTD_ps_auto),
1454
+ * but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable force enable/disable the feature.
1418
1455
  */
1419
1456
  ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */
1420
1457
  ZSTD_ps_enable = 1, /* Force-enable the feature */
1421
1458
  ZSTD_ps_disable = 2 /* Do not use the feature */
1422
- } ZSTD_paramSwitch_e;
1459
+ } ZSTD_ParamSwitch_e;
1460
+ #define ZSTD_paramSwitch_e ZSTD_ParamSwitch_e /* old name */
1423
1461
 
1424
1462
  /***************************************
1425
1463
  * Frame header and size functions
@@ -1464,34 +1502,36 @@ ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src,
1464
1502
  ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
1465
1503
 
1466
1504
  /*! ZSTD_frameHeaderSize() :
1467
- * srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX.
1505
+ * srcSize must be large enough, aka >= ZSTD_FRAMEHEADERSIZE_PREFIX.
1468
1506
  * @return : size of the Frame Header,
1469
1507
  * or an error code (if srcSize is too small) */
1470
1508
  ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1471
1509
 
1472
- typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
1510
+ typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_FrameType_e;
1511
+ #define ZSTD_frameType_e ZSTD_FrameType_e /* old name */
1473
1512
  typedef struct {
1474
1513
  unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
1475
1514
  unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
1476
1515
  unsigned blockSizeMax;
1477
- ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
1516
+ ZSTD_FrameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
1478
1517
  unsigned headerSize;
1479
- unsigned dictID;
1518
+ unsigned dictID; /* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */
1480
1519
  unsigned checksumFlag;
1481
1520
  unsigned _reserved1;
1482
1521
  unsigned _reserved2;
1483
- } ZSTD_frameHeader;
1522
+ } ZSTD_FrameHeader;
1523
+ #define ZSTD_frameHeader ZSTD_FrameHeader /* old name */
1484
1524
 
1485
1525
  /*! ZSTD_getFrameHeader() :
1486
- * decode Frame Header, or requires larger `srcSize`.
1487
- * @return : 0, `zfhPtr` is correctly filled,
1488
- * >0, `srcSize` is too small, value is wanted `srcSize` amount,
1526
+ * decode Frame Header into `zfhPtr`, or requires larger `srcSize`.
1527
+ * @return : 0 => header is complete, `zfhPtr` is correctly filled,
1528
+ * >0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled,
1489
1529
  * or an error code, which can be tested using ZSTD_isError() */
1490
- ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
1530
+ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize);
1491
1531
  /*! ZSTD_getFrameHeader_advanced() :
1492
1532
  * same as ZSTD_getFrameHeader(),
1493
1533
  * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
1494
- ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
1534
+ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
1495
1535
 
1496
1536
  /*! ZSTD_decompressionMargin() :
1497
1537
  * Zstd supports in-place decompression, where the input and output buffers overlap.
@@ -1539,9 +1579,10 @@ ZSTDLIB_STATIC_API size_t ZSTD_decompressionMargin(const void* src, size_t srcSi
1539
1579
  ))
1540
1580
 
1541
1581
  typedef enum {
1542
- ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
1543
- ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
1544
- } ZSTD_sequenceFormat_e;
1582
+ ZSTD_sf_noBlockDelimiters = 0, /* ZSTD_Sequence[] has no block delimiters, just sequences */
1583
+ ZSTD_sf_explicitBlockDelimiters = 1 /* ZSTD_Sequence[] contains explicit block delimiters */
1584
+ } ZSTD_SequenceFormat_e;
1585
+ #define ZSTD_sequenceFormat_e ZSTD_SequenceFormat_e /* old name */
1545
1586
 
1546
1587
  /*! ZSTD_sequenceBound() :
1547
1588
  * `srcSize` : size of the input buffer
@@ -1565,7 +1606,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
1565
1606
  * @param zc The compression context to be used for ZSTD_compress2(). Set any
1566
1607
  * compression parameters you need on this context.
1567
1608
  * @param outSeqs The output sequences buffer of size @p outSeqsSize
1568
- * @param outSeqsSize The size of the output sequences buffer.
1609
+ * @param outSeqsCapacity The size of the output sequences buffer.
1569
1610
  * ZSTD_sequenceBound(srcSize) is an upper bound on the number
1570
1611
  * of sequences that can be generated.
1571
1612
  * @param src The source buffer to generate sequences from of size @p srcSize.
@@ -1583,7 +1624,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
1583
1624
  ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()")
1584
1625
  ZSTDLIB_STATIC_API size_t
1585
1626
  ZSTD_generateSequences(ZSTD_CCtx* zc,
1586
- ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1627
+ ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
1587
1628
  const void* src, size_t srcSize);
1588
1629
 
1589
1630
  /*! ZSTD_mergeBlockDelimiters() :
@@ -1603,7 +1644,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, si
1603
1644
  * Compress an array of ZSTD_Sequence, associated with @src buffer, into dst.
1604
1645
  * @src contains the entire input (not just the literals).
1605
1646
  * If @srcSize > sum(sequence.length), the remaining bytes are considered all literals
1606
- * If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
1647
+ * If a dictionary is included, then the cctx should reference the dict (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.).
1607
1648
  * The entire source is compressed into a single frame.
1608
1649
  *
1609
1650
  * The compression behavior changes based on cctx params. In particular:
@@ -1612,11 +1653,17 @@ ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, si
1612
1653
  * the block size derived from the cctx, and sequences may be split. This is the default setting.
1613
1654
  *
1614
1655
  * If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
1615
- * block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
1656
+ * valid block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
1616
1657
  *
1617
- * If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
1618
- * behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
1619
- * specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
1658
+ * When ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, it's possible to decide generating repcodes
1659
+ * using the advanced parameter ZSTD_c_repcodeResolution. Repcodes will improve compression ratio, though the benefit
1660
+ * can vary greatly depending on Sequences. On the other hand, repcode resolution is an expensive operation.
1661
+ * By default, it's disabled at low (<10) compression levels, and enabled above the threshold (>=10).
1662
+ * ZSTD_c_repcodeResolution makes it possible to directly manage this processing in either direction.
1663
+ *
1664
+ * If ZSTD_c_validateSequences == 0, this function blindly accepts the Sequences provided. Invalid Sequences cause undefined
1665
+ * behavior. If ZSTD_c_validateSequences == 1, then the function will detect invalid Sequences (see doc/zstd_compression_format.md for
1666
+ * specifics regarding offset/matchlength requirements) and then bail out and return an error.
1620
1667
  *
1621
1668
  * In addition to the two adjustable experimental params, there are other important cctx params.
1622
1669
  * - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN.
@@ -1624,15 +1671,42 @@ ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, si
1624
1671
  * - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
1625
1672
  * is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
1626
1673
  *
1627
- * Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
1628
- * Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
1629
- * and cannot emit an RLE block that disagrees with the repcode history
1674
+ * Note: Repcodes are, as of now, always re-calculated within this function, ZSTD_Sequence.rep is effectively unused.
1675
+ * Dev Note: Once ability to ingest repcodes become available, the explicit block delims mode must respect those repcodes exactly,
1676
+ * and cannot emit an RLE block that disagrees with the repcode history.
1677
+ * @return : final compressed size, or a ZSTD error code.
1678
+ */
1679
+ ZSTDLIB_STATIC_API size_t
1680
+ ZSTD_compressSequences(ZSTD_CCtx* cctx,
1681
+ void* dst, size_t dstCapacity,
1682
+ const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
1683
+ const void* src, size_t srcSize);
1684
+
1685
+
1686
+ /*! ZSTD_compressSequencesAndLiterals() :
1687
+ * This is a variant of ZSTD_compressSequences() which,
1688
+ * instead of receiving (src,srcSize) as input parameter, receives (literals,litSize),
1689
+ * aka all the literals, already extracted and laid out into a single continuous buffer.
1690
+ * This can be useful if the process generating the sequences also happens to generate the buffer of literals,
1691
+ * thus skipping an extraction + caching stage.
1692
+ * It's a speed optimization, useful when the right conditions are met,
1693
+ * but it also features the following limitations:
1694
+ * - Only supports explicit delimiter mode
1695
+ * - Currently does not support Sequences validation (so input Sequences are trusted)
1696
+ * - Not compatible with frame checksum, which must be disabled
1697
+ * - If any block is incompressible, will fail and return an error
1698
+ * - @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error.
1699
+ * - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals.
1700
+ * @litBufCapacity must be at least 8 bytes larger than @litSize.
1701
+ * - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
1630
1702
  * @return : final compressed size, or a ZSTD error code.
1631
1703
  */
1632
1704
  ZSTDLIB_STATIC_API size_t
1633
- ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
1634
- const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
1635
- const void* src, size_t srcSize);
1705
+ ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
1706
+ void* dst, size_t dstCapacity,
1707
+ const ZSTD_Sequence* inSeqs, size_t nbSequences,
1708
+ const void* literals, size_t litSize, size_t litBufCapacity,
1709
+ size_t decompressedSize);
1636
1710
 
1637
1711
 
1638
1712
  /*! ZSTD_writeSkippableFrame() :
@@ -1640,8 +1714,8 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
1640
1714
  *
1641
1715
  * Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number,
1642
1716
  * ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
1643
- * As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
1644
- * the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1717
+ * As such, the parameter magicVariant controls the exact skippable frame magic number variant used,
1718
+ * so the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1645
1719
  *
1646
1720
  * Returns an error if destination buffer is not large enough, if the source size is not representable
1647
1721
  * with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
@@ -1649,26 +1723,28 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
1649
1723
  * @return : number of bytes written or a ZSTD error.
1650
1724
  */
1651
1725
  ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
1652
- const void* src, size_t srcSize, unsigned magicVariant);
1726
+ const void* src, size_t srcSize,
1727
+ unsigned magicVariant);
1653
1728
 
1654
1729
  /*! ZSTD_readSkippableFrame() :
1655
- * Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
1730
+ * Retrieves the content of a zstd skippable frame starting at @src, and writes it to @dst buffer.
1656
1731
  *
1657
- * The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
1658
- * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
1659
- * in the magicVariant.
1732
+ * The parameter @magicVariant will receive the magicVariant that was supplied when the frame was written,
1733
+ * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START.
1734
+ * This can be NULL if the caller is not interested in the magicVariant.
1660
1735
  *
1661
1736
  * Returns an error if destination buffer is not large enough, or if the frame is not skippable.
1662
1737
  *
1663
1738
  * @return : number of bytes written or a ZSTD error.
1664
1739
  */
1665
- ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
1666
- const void* src, size_t srcSize);
1740
+ ZSTDLIB_STATIC_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity,
1741
+ unsigned* magicVariant,
1742
+ const void* src, size_t srcSize);
1667
1743
 
1668
1744
  /*! ZSTD_isSkippableFrame() :
1669
1745
  * Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
1670
1746
  */
1671
- ZSTDLIB_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1747
+ ZSTDLIB_STATIC_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1672
1748
 
1673
1749
 
1674
1750
 
@@ -1796,7 +1872,15 @@ static
1796
1872
  #ifdef __GNUC__
1797
1873
  __attribute__((__unused__))
1798
1874
  #endif
1875
+
1876
+ #if defined(__clang__) && __clang_major__ >= 5
1877
+ #pragma clang diagnostic push
1878
+ #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
1879
+ #endif
1799
1880
  ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
1881
+ #if defined(__clang__) && __clang_major__ >= 5
1882
+ #pragma clang diagnostic pop
1883
+ #endif
1800
1884
 
1801
1885
  ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1802
1886
  ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
@@ -1976,7 +2060,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
1976
2060
  * See the comments on that enum for an explanation of the feature. */
1977
2061
  #define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
1978
2062
 
1979
- /* Controlled with ZSTD_paramSwitch_e enum.
2063
+ /* Controlled with ZSTD_ParamSwitch_e enum.
1980
2064
  * Default is ZSTD_ps_auto.
1981
2065
  * Set to ZSTD_ps_disable to never compress literals.
1982
2066
  * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals
@@ -2117,22 +2201,46 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
2117
2201
  /* ZSTD_c_validateSequences
2118
2202
  * Default is 0 == disabled. Set to 1 to enable sequence validation.
2119
2203
  *
2120
- * For use with sequence compression API: ZSTD_compressSequences().
2121
- * Designates whether or not we validate sequences provided to ZSTD_compressSequences()
2204
+ * For use with sequence compression API: ZSTD_compressSequences*().
2205
+ * Designates whether or not provided sequences are validated within ZSTD_compressSequences*()
2122
2206
  * during function execution.
2123
2207
  *
2124
- * Without validation, providing a sequence that does not conform to the zstd spec will cause
2125
- * undefined behavior, and may produce a corrupted block.
2208
+ * When Sequence validation is disabled (default), Sequences are compressed as-is,
2209
+ * so they must correct, otherwise it would result in a corruption error.
2126
2210
  *
2127
- * With validation enabled, if sequence is invalid (see doc/zstd_compression_format.md for
2211
+ * Sequence validation adds some protection, by ensuring that all values respect boundary conditions.
2212
+ * If a Sequence is detected invalid (see doc/zstd_compression_format.md for
2128
2213
  * specifics regarding offset/matchlength requirements) then the function will bail out and
2129
2214
  * return an error.
2130
- *
2131
2215
  */
2132
2216
  #define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
2133
2217
 
2134
- /* ZSTD_c_useBlockSplitter
2135
- * Controlled with ZSTD_paramSwitch_e enum.
2218
+ /* ZSTD_c_blockSplitterLevel
2219
+ * note: this parameter only influences the first splitter stage,
2220
+ * which is active before producing the sequences.
2221
+ * ZSTD_c_splitAfterSequences controls the next splitter stage,
2222
+ * which is active after sequence production.
2223
+ * Note that both can be combined.
2224
+ * Allowed values are between 0 and ZSTD_BLOCKSPLITTER_LEVEL_MAX included.
2225
+ * 0 means "auto", which will select a value depending on current ZSTD_c_strategy.
2226
+ * 1 means no splitting.
2227
+ * Then, values from 2 to 6 are sorted in increasing cpu load order.
2228
+ *
2229
+ * Note that currently the first block is never split,
2230
+ * to ensure expansion guarantees in presence of incompressible data.
2231
+ */
2232
+ #define ZSTD_BLOCKSPLITTER_LEVEL_MAX 6
2233
+ #define ZSTD_c_blockSplitterLevel ZSTD_c_experimentalParam20
2234
+
2235
+ /* ZSTD_c_splitAfterSequences
2236
+ * This is a stronger splitter algorithm,
2237
+ * based on actual sequences previously produced by the selected parser.
2238
+ * It's also slower, and as a consequence, mostly used for high compression levels.
2239
+ * While the post-splitter does overlap with the pre-splitter,
2240
+ * both can nonetheless be combined,
2241
+ * notably with ZSTD_c_blockSplitterLevel at ZSTD_BLOCKSPLITTER_LEVEL_MAX,
2242
+ * resulting in higher compression ratio than just one of them.
2243
+ *
2136
2244
  * Default is ZSTD_ps_auto.
2137
2245
  * Set to ZSTD_ps_disable to never use block splitter.
2138
2246
  * Set to ZSTD_ps_enable to always use block splitter.
@@ -2140,10 +2248,10 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
2140
2248
  * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
2141
2249
  * block splitting based on the compression parameters.
2142
2250
  */
2143
- #define ZSTD_c_useBlockSplitter ZSTD_c_experimentalParam13
2251
+ #define ZSTD_c_splitAfterSequences ZSTD_c_experimentalParam13
2144
2252
 
2145
2253
  /* ZSTD_c_useRowMatchFinder
2146
- * Controlled with ZSTD_paramSwitch_e enum.
2254
+ * Controlled with ZSTD_ParamSwitch_e enum.
2147
2255
  * Default is ZSTD_ps_auto.
2148
2256
  * Set to ZSTD_ps_disable to never use row-based matchfinder.
2149
2257
  * Set to ZSTD_ps_enable to force usage of row-based matchfinder.
@@ -2175,7 +2283,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
2175
2283
  #define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
2176
2284
 
2177
2285
  /* ZSTD_c_prefetchCDictTables
2178
- * Controlled with ZSTD_paramSwitch_e enum. Default is ZSTD_ps_auto.
2286
+ * Controlled with ZSTD_ParamSwitch_e enum. Default is ZSTD_ps_auto.
2179
2287
  *
2180
2288
  * In some situations, zstd uses CDict tables in-place rather than copying them
2181
2289
  * into the working context. (See docs on ZSTD_dictAttachPref_e above for details).
@@ -2219,19 +2327,21 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
2219
2327
  * that overrides the default ZSTD_BLOCKSIZE_MAX. It cannot be used to set upper
2220
2328
  * bounds greater than ZSTD_BLOCKSIZE_MAX or bounds lower than 1KB (will make
2221
2329
  * compressBound() inaccurate). Only currently meant to be used for testing.
2222
- *
2223
2330
  */
2224
2331
  #define ZSTD_c_maxBlockSize ZSTD_c_experimentalParam18
2225
2332
 
2226
- /* ZSTD_c_searchForExternalRepcodes
2227
- * This parameter affects how zstd parses external sequences, such as sequences
2228
- * provided through the compressSequences() API or from an external block-level
2229
- * sequence producer.
2333
+ /* ZSTD_c_repcodeResolution
2334
+ * This parameter only has an effect if ZSTD_c_blockDelimiters is
2335
+ * set to ZSTD_sf_explicitBlockDelimiters (may change in the future).
2336
+ *
2337
+ * This parameter affects how zstd parses external sequences,
2338
+ * provided via the ZSTD_compressSequences*() API
2339
+ * or from an external block-level sequence producer.
2230
2340
  *
2231
- * If set to ZSTD_ps_enable, the library will check for repeated offsets in
2341
+ * If set to ZSTD_ps_enable, the library will check for repeated offsets within
2232
2342
  * external sequences, even if those repcodes are not explicitly indicated in
2233
2343
  * the "rep" field. Note that this is the only way to exploit repcode matches
2234
- * while using compressSequences() or an external sequence producer, since zstd
2344
+ * while using compressSequences*() or an external sequence producer, since zstd
2235
2345
  * currently ignores the "rep" field of external sequences.
2236
2346
  *
2237
2347
  * If set to ZSTD_ps_disable, the library will not exploit repeated offsets in
@@ -2240,12 +2350,11 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
2240
2350
  * compression ratio.
2241
2351
  *
2242
2352
  * The default value is ZSTD_ps_auto, for which the library will enable/disable
2243
- * based on compression level.
2244
- *
2245
- * Note: for now, this param only has an effect if ZSTD_c_blockDelimiters is
2246
- * set to ZSTD_sf_explicitBlockDelimiters. That may change in the future.
2353
+ * based on compression level (currently: level<10 disables, level>=10 enables).
2247
2354
  */
2248
- #define ZSTD_c_searchForExternalRepcodes ZSTD_c_experimentalParam19
2355
+ #define ZSTD_c_repcodeResolution ZSTD_c_experimentalParam19
2356
+ #define ZSTD_c_searchForExternalRepcodes ZSTD_c_experimentalParam19 /* older name */
2357
+
2249
2358
 
2250
2359
  /*! ZSTD_CCtx_getParameter() :
2251
2360
  * Get the requested compression parameter value, selected by enum ZSTD_cParameter,
@@ -2952,7 +3061,7 @@ size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_
2952
3061
  >0 : `srcSize` is too small, please provide at least result bytes on next attempt.
2953
3062
  errorCode, which can be tested using ZSTD_isError().
2954
3063
 
2955
- It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
3064
+ It fills a ZSTD_FrameHeader structure with important information to correctly decode the frame,
2956
3065
  such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
2957
3066
  Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
2958
3067
  As a consequence, check that values remain within valid application range.
@@ -3082,8 +3191,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_
3082
3191
  ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
3083
3192
  ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
3084
3193
 
3085
- #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
3086
-
3087
3194
  #if defined (__cplusplus)
3088
3195
  }
3089
3196
  #endif
3197
+
3198
+ #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */