zstdlib 0.7.0-x86-mingw32 → 0.8.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/ext/zstdlib/extconf.rb +1 -1
  4. data/ext/zstdlib/ruby/zlib-3.0/zstdlib.c +4994 -0
  5. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/bitstream.h +25 -16
  6. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/compiler.h +118 -4
  7. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/cpu.h +1 -3
  8. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.c +1 -1
  9. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.h +12 -19
  10. data/ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c +362 -0
  11. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.c +2 -1
  12. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.h +3 -3
  13. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse.h +40 -12
  14. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse_decompress.c +139 -22
  15. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/huf.h +29 -7
  16. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/mem.h +69 -98
  17. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.c +23 -17
  18. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.h +2 -2
  19. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.c +6 -5
  20. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.h +0 -0
  21. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.c +20 -60
  22. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.h +2 -2
  23. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_common.c +10 -10
  24. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h +111 -0
  25. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_internal.h +105 -62
  26. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h +154 -0
  27. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/fse_compress.c +31 -24
  28. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.c +27 -29
  29. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.h +2 -2
  30. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/huf_compress.c +265 -126
  31. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress.c +2843 -728
  32. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_internal.h +305 -63
  33. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.c +8 -8
  34. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.h +1 -1
  35. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.c +29 -7
  36. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.h +1 -1
  37. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.c +22 -295
  38. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.h +1 -1
  39. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_cwksp.h +204 -67
  40. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.c +25 -25
  41. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.h +1 -1
  42. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.c +23 -23
  43. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.h +1 -1
  44. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c +2184 -0
  45. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h +125 -0
  46. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.c +314 -211
  47. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.h +9 -2
  48. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h +103 -0
  49. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.c +191 -46
  50. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.h +1 -1
  51. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstdmt_compress.c +93 -415
  52. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h +110 -0
  53. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/huf_decompress.c +342 -239
  54. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.c +9 -9
  55. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.h +2 -2
  56. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress.c +369 -87
  57. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.c +191 -75
  58. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.h +6 -3
  59. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_internal.h +27 -11
  60. data/ext/zstdlib/zstd-1.5.0/lib/zdict.h +452 -0
  61. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/zstd.h +568 -126
  62. data/ext/zstdlib/{zstd-1.4.5/lib/common → zstd-1.5.0/lib}/zstd_errors.h +2 -1
  63. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzclose.c +0 -0
  64. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzcompatibility.h +1 -1
  65. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzguts.h +0 -0
  66. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzlib.c +0 -0
  67. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzread.c +0 -0
  68. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzwrite.c +0 -0
  69. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.c +126 -44
  70. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.h +1 -1
  71. data/lib/2.2/zstdlib.so +0 -0
  72. data/lib/2.3/zstdlib.so +0 -0
  73. data/lib/2.4/zstdlib.so +0 -0
  74. data/lib/2.5/zstdlib.so +0 -0
  75. data/lib/2.6/zstdlib.so +0 -0
  76. data/lib/2.7/zstdlib.so +0 -0
  77. metadata +69 -64
  78. data/ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c +0 -216
  79. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c +0 -1138
  80. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h +0 -67
  81. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h +0 -192
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) Yann Collet, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under both the BSD-style license (found in the
@@ -71,17 +71,22 @@ extern "C" {
71
71
 
72
72
  /*------ Version ------*/
73
73
  #define ZSTD_VERSION_MAJOR 1
74
- #define ZSTD_VERSION_MINOR 4
75
- #define ZSTD_VERSION_RELEASE 5
76
-
74
+ #define ZSTD_VERSION_MINOR 5
75
+ #define ZSTD_VERSION_RELEASE 0
77
76
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
78
- ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< to check runtime library version */
77
+
78
+ /*! ZSTD_versionNumber() :
79
+ * Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */
80
+ ZSTDLIB_API unsigned ZSTD_versionNumber(void);
79
81
 
80
82
  #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
81
83
  #define ZSTD_QUOTE(str) #str
82
84
  #define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
83
85
  #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
84
- ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
86
+
87
+ /*! ZSTD_versionString() :
88
+ * Return runtime library version, like "1.4.5". Requires v1.3.0+. */
89
+ ZSTDLIB_API const char* ZSTD_versionString(void);
85
90
 
86
91
  /* *************************************
87
92
  * Default constant
@@ -104,7 +109,6 @@ ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
104
109
  #define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
105
110
 
106
111
 
107
-
108
112
  /***************************************
109
113
  * Simple API
110
114
  ***************************************/
@@ -161,7 +165,7 @@ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t
161
165
  * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
162
166
  ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
163
167
 
164
- /*! ZSTD_findFrameCompressedSize() :
168
+ /*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+
165
169
  * `src` should point to the start of a ZSTD frame or skippable frame.
166
170
  * `srcSize` must be >= first frame size
167
171
  * @return : the compressed size of the first frame starting at `src`,
@@ -175,8 +179,9 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
175
179
  ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
176
180
  ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
177
181
  ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
178
- ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */
182
+ ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
179
183
  ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
184
+ ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
180
185
 
181
186
 
182
187
  /***************************************
@@ -194,7 +199,7 @@ ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compres
194
199
  */
195
200
  typedef struct ZSTD_CCtx_s ZSTD_CCtx;
196
201
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
197
- ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
202
+ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
198
203
 
199
204
  /*! ZSTD_compressCCtx() :
200
205
  * Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
@@ -217,7 +222,7 @@ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
217
222
  * Use one context per thread for parallel execution. */
218
223
  typedef struct ZSTD_DCtx_s ZSTD_DCtx;
219
224
  ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
220
- ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
225
+ ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */
221
226
 
222
227
  /*! ZSTD_decompressDCtx() :
223
228
  * Same as ZSTD_decompress(),
@@ -229,9 +234,9 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
229
234
  const void* src, size_t srcSize);
230
235
 
231
236
 
232
- /***************************************
233
- * Advanced compression API
234
- ***************************************/
237
+ /*********************************************
238
+ * Advanced compression API (Requires v1.4.0+)
239
+ **********************************************/
235
240
 
236
241
  /* API design :
237
242
  * Parameters are pushed one by one into an existing context,
@@ -261,7 +266,6 @@ typedef enum { ZSTD_fast=1,
261
266
  Only the order (from fast to strong) is guaranteed */
262
267
  } ZSTD_strategy;
263
268
 
264
-
265
269
  typedef enum {
266
270
 
267
271
  /* compression parameters
@@ -327,14 +331,15 @@ typedef enum {
327
331
  * The higher the value of selected strategy, the more complex it is,
328
332
  * resulting in stronger and slower compression.
329
333
  * Special: value 0 means "use default strategy". */
330
-
331
334
  /* LDM mode parameters */
332
335
  ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
333
336
  * This parameter is designed to improve compression ratio
334
337
  * for large inputs, by finding large matches at long distance.
335
338
  * It increases memory usage and window size.
336
339
  * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
337
- * except when expressly set to a different value. */
340
+ * except when expressly set to a different value.
341
+ * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
342
+ * compression strategy >= ZSTD_btopt (== compression level 16+) */
338
343
  ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
339
344
  * Larger values increase memory usage and compression ratio,
340
345
  * but decrease compression speed.
@@ -365,20 +370,24 @@ typedef enum {
365
370
  ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
366
371
 
367
372
  /* multi-threading parameters */
368
- /* These parameters are only useful if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
369
- * They return an error otherwise. */
373
+ /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
374
+ * Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
375
+ * In a situation where it's unknown if the linked library supports multi-threading or not,
376
+ * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
377
+ */
370
378
  ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
371
- * When nbWorkers >= 1, triggers asynchronous mode when used with ZSTD_compressStream*() :
379
+ * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
372
380
  * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
373
- * while compression work is performed in parallel, within worker threads.
381
+ * while compression is performed in parallel, within worker thread(s).
374
382
  * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
375
383
  * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
376
384
  * More workers improve speed, but also increase memory usage.
377
- * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */
385
+ * Default value is `0`, aka "single-threaded mode" : no worker is spawned,
386
+ * compression is performed inside Caller's thread, and all invocations are blocking */
378
387
  ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
379
388
  * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
380
389
  * 0 means default, which is dynamically determined based on compression parameters.
381
- * Job size must be a minimum of overlap size, or 1 MB, whichever is largest.
390
+ * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
382
391
  * The minimum size is automatically and transparently enforced. */
383
392
  ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
384
393
  * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
@@ -403,6 +412,13 @@ typedef enum {
403
412
  * ZSTD_c_literalCompressionMode
404
413
  * ZSTD_c_targetCBlockSize
405
414
  * ZSTD_c_srcSizeHint
415
+ * ZSTD_c_enableDedicatedDictSearch
416
+ * ZSTD_c_stableInBuffer
417
+ * ZSTD_c_stableOutBuffer
418
+ * ZSTD_c_blockDelimiters
419
+ * ZSTD_c_validateSequences
420
+ * ZSTD_c_splitBlocks
421
+ * ZSTD_c_useRowMatchFinder
406
422
  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
407
423
  * note : never ever use experimentalParam? names directly;
408
424
  * also, the enums values themselves are unstable and can still change.
@@ -413,7 +429,15 @@ typedef enum {
413
429
  ZSTD_c_experimentalParam4=1001,
414
430
  ZSTD_c_experimentalParam5=1002,
415
431
  ZSTD_c_experimentalParam6=1003,
416
- ZSTD_c_experimentalParam7=1004
432
+ ZSTD_c_experimentalParam7=1004,
433
+ ZSTD_c_experimentalParam8=1005,
434
+ ZSTD_c_experimentalParam9=1006,
435
+ ZSTD_c_experimentalParam10=1007,
436
+ ZSTD_c_experimentalParam11=1008,
437
+ ZSTD_c_experimentalParam12=1009,
438
+ ZSTD_c_experimentalParam13=1010,
439
+ ZSTD_c_experimentalParam14=1011,
440
+ ZSTD_c_experimentalParam15=1012
417
441
  } ZSTD_cParameter;
418
442
 
419
443
  typedef struct {
@@ -498,9 +522,9 @@ ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
498
522
  const void* src, size_t srcSize);
499
523
 
500
524
 
501
- /***************************************
502
- * Advanced decompression API
503
- ***************************************/
525
+ /***********************************************
526
+ * Advanced decompression API (Requires v1.4.0+)
527
+ ************************************************/
504
528
 
505
529
  /* The advanced API pushes parameters one by one into an existing DCtx context.
506
530
  * Parameters are sticky, and remain valid for all following frames
@@ -524,11 +548,15 @@ typedef enum {
524
548
  * At the time of this writing, they include :
525
549
  * ZSTD_d_format
526
550
  * ZSTD_d_stableOutBuffer
551
+ * ZSTD_d_forceIgnoreChecksum
552
+ * ZSTD_d_refMultipleDDicts
527
553
  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
528
554
  * note : never ever use experimentalParam? names directly
529
555
  */
530
556
  ZSTD_d_experimentalParam1=1000,
531
- ZSTD_d_experimentalParam2=1001
557
+ ZSTD_d_experimentalParam2=1001,
558
+ ZSTD_d_experimentalParam3=1002,
559
+ ZSTD_d_experimentalParam4=1003
532
560
 
533
561
  } ZSTD_dParameter;
534
562
 
@@ -642,7 +670,7 @@ typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same
642
670
  /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
643
671
  /*===== ZSTD_CStream management functions =====*/
644
672
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
645
- ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
673
+ ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */
646
674
 
647
675
  /*===== Streaming compression functions =====*/
648
676
  typedef enum {
@@ -658,14 +686,15 @@ typedef enum {
658
686
  : note : multithreaded compression will block to flush as much output as possible. */
659
687
  } ZSTD_EndDirective;
660
688
 
661
- /*! ZSTD_compressStream2() :
689
+ /*! ZSTD_compressStream2() : Requires v1.4.0+
662
690
  * Behaves about the same as ZSTD_compressStream, with additional control on end directive.
663
691
  * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
664
692
  * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
665
693
  * - output->pos must be <= dstCapacity, input->pos must be <= srcSize
666
694
  * - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
695
+ * - endOp must be a valid directive
667
696
  * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
668
- * - When nbWorkers>=1, function is non-blocking : it just acquires a copy of input, and distributes jobs to internal worker threads, flush whatever is available,
697
+ * - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available,
669
698
  * and then immediately returns, just indicating that there is some data remaining to be flushed.
670
699
  * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
671
700
  * - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.
@@ -703,11 +732,11 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
703
732
 
704
733
 
705
734
  /* *****************************************************************************
706
- * This following is a legacy streaming API.
735
+ * This following is a legacy streaming API, available since v1.0+ .
707
736
  * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
708
737
  * It is redundant, but remains fully supported.
709
- * Advanced parameters and dictionary compression can only be used through the
710
- * new API.
738
+ * Streaming in combination with advanced parameters and dictionary compression
739
+ * can only be used through the new API.
711
740
  ******************************************************************************/
712
741
 
713
742
  /*!
@@ -762,7 +791,7 @@ typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same
762
791
  /* For compatibility with versions <= v1.2.0, prefer differentiating them. */
763
792
  /*===== ZSTD_DStream management functions =====*/
764
793
  ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
765
- ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
794
+ ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */
766
795
 
767
796
  /*===== Streaming decompression functions =====*/
768
797
 
@@ -785,7 +814,7 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
785
814
  /*! ZSTD_compress_usingDict() :
786
815
  * Compression at an explicit compression level using a Dictionary.
787
816
  * A dictionary can be any arbitrary data segment (also called a prefix),
788
- * or a buffer with specified information (see dictBuilder/zdict.h).
817
+ * or a buffer with specified information (see zdict.h).
789
818
  * Note : This function loads the dictionary, resulting in significant startup delay.
790
819
  * It's intended for a dictionary used only once.
791
820
  * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */
@@ -828,7 +857,8 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize
828
857
  int compressionLevel);
829
858
 
830
859
  /*! ZSTD_freeCDict() :
831
- * Function frees memory allocated by ZSTD_createCDict(). */
860
+ * Function frees memory allocated by ZSTD_createCDict().
861
+ * If a NULL pointer is passed, no operation is performed. */
832
862
  ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
833
863
 
834
864
  /*! ZSTD_compress_usingCDict() :
@@ -850,7 +880,8 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
850
880
  ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
851
881
 
852
882
  /*! ZSTD_freeDDict() :
853
- * Function frees memory allocated with ZSTD_createDDict() */
883
+ * Function frees memory allocated with ZSTD_createDDict()
884
+ * If a NULL pointer is passed, no operation is performed. */
854
885
  ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
855
886
 
856
887
  /*! ZSTD_decompress_usingDDict() :
@@ -866,19 +897,25 @@ ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
866
897
  * Dictionary helper functions
867
898
  *******************************/
868
899
 
869
- /*! ZSTD_getDictID_fromDict() :
900
+ /*! ZSTD_getDictID_fromDict() : Requires v1.4.0+
870
901
  * Provides the dictID stored within dictionary.
871
902
  * if @return == 0, the dictionary is not conformant with Zstandard specification.
872
903
  * It can still be loaded, but as a content-only dictionary. */
873
904
  ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
874
905
 
875
- /*! ZSTD_getDictID_fromDDict() :
906
+ /*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+
907
+ * Provides the dictID of the dictionary loaded into `cdict`.
908
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
909
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
910
+ ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
911
+
912
+ /*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+
876
913
  * Provides the dictID of the dictionary loaded into `ddict`.
877
914
  * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
878
915
  * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
879
916
  ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
880
917
 
881
- /*! ZSTD_getDictID_fromFrame() :
918
+ /*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+
882
919
  * Provides the dictID required to decompressed the frame stored within `src`.
883
920
  * If @return == 0, the dictID could not be decoded.
884
921
  * This could for one of the following reasons :
@@ -892,7 +929,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
892
929
 
893
930
 
894
931
  /*******************************************************************************
895
- * Advanced dictionary and prefix API
932
+ * Advanced dictionary and prefix API (Requires v1.4.0+)
896
933
  *
897
934
  * This API allows dictionaries to be used with ZSTD_compress2(),
898
935
  * ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and
@@ -901,7 +938,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
901
938
  ******************************************************************************/
902
939
 
903
940
 
904
- /*! ZSTD_CCtx_loadDictionary() :
941
+ /*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+
905
942
  * Create an internal CDict from `dict` buffer.
906
943
  * Decompression will have to use same dictionary.
907
944
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
@@ -920,11 +957,11 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
920
957
  * to precisely select how dictionary content must be interpreted. */
921
958
  ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
922
959
 
923
- /*! ZSTD_CCtx_refCDict() :
960
+ /*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
924
961
  * Reference a prepared dictionary, to be used for all next compressed frames.
925
962
  * Note that compression parameters are enforced from within CDict,
926
963
  * and supersede any compression parameter previously set within CCtx.
927
- * The parameters ignored are labled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
964
+ * The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
928
965
  * The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.
929
966
  * The dictionary will remain valid for future compressed frames using same CCtx.
930
967
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
@@ -934,7 +971,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
934
971
  * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */
935
972
  ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
936
973
 
937
- /*! ZSTD_CCtx_refPrefix() :
974
+ /*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+
938
975
  * Reference a prefix (single-usage dictionary) for next compressed frame.
939
976
  * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
940
977
  * Decompression will need same prefix to properly regenerate data.
@@ -955,7 +992,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
955
992
  ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
956
993
  const void* prefix, size_t prefixSize);
957
994
 
958
- /*! ZSTD_DCtx_loadDictionary() :
995
+ /*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
959
996
  * Create an internal DDict from dict buffer,
960
997
  * to be used to decompress next frames.
961
998
  * The dictionary remains valid for all future frames, until explicitly invalidated.
@@ -972,9 +1009,16 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
972
1009
  */
973
1010
  ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
974
1011
 
975
- /*! ZSTD_DCtx_refDDict() :
1012
+ /*! ZSTD_DCtx_refDDict() : Requires v1.4.0+
976
1013
  * Reference a prepared dictionary, to be used to decompress next frames.
977
1014
  * The dictionary remains active for decompression of future frames using same DCtx.
1015
+ *
1016
+ * If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
1017
+ * will store the DDict references in a table, and the DDict used for decompression
1018
+ * will be determined at decompression time, as per the dict ID in the frame.
1019
+ * The memory for the table is allocated on the first call to refDDict, and can be
1020
+ * freed with ZSTD_freeDCtx().
1021
+ *
978
1022
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
979
1023
  * Note 1 : Currently, only one dictionary can be managed.
980
1024
  * Referencing a new dictionary effectively "discards" any previous one.
@@ -983,7 +1027,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
983
1027
  */
984
1028
  ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
985
1029
 
986
- /*! ZSTD_DCtx_refPrefix() :
1030
+ /*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+
987
1031
  * Reference a prefix (single-usage dictionary) to decompress next frame.
988
1032
  * This is the reverse operation of ZSTD_CCtx_refPrefix(),
989
1033
  * and must use the same prefix as the one used during compression.
@@ -1004,7 +1048,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
1004
1048
 
1005
1049
  /* === Memory management === */
1006
1050
 
1007
- /*! ZSTD_sizeof_*() :
1051
+ /*! ZSTD_sizeof_*() : Requires v1.4.0+
1008
1052
  * These functions give the _current_ memory usage of selected object.
1009
1053
  * Note that object memory usage can evolve (increase or decrease) over time. */
1010
1054
  ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
@@ -1029,6 +1073,28 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1029
1073
  #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
1030
1074
  #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
1031
1075
 
1076
+ /* Deprecation warnings :
1077
+ * Should these warnings be a problem, it is generally possible to disable them,
1078
+ * typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual.
1079
+ * Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS.
1080
+ */
1081
+ #ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS
1082
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
1083
+ #else
1084
+ # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
1085
+ # define ZSTD_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
1086
+ # elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
1087
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
1088
+ # elif defined(__GNUC__) && (__GNUC__ >= 3)
1089
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
1090
+ # elif defined(_MSC_VER)
1091
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
1092
+ # else
1093
+ # pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler")
1094
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_API
1095
+ # endif
1096
+ #endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */
1097
+
1032
1098
  /****************************************************************************************
1033
1099
  * experimental API (static linking only)
1034
1100
  ****************************************************************************************
@@ -1100,21 +1166,40 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1100
1166
  typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
1101
1167
 
1102
1168
  typedef struct {
1103
- unsigned int matchPos; /* Match pos in dst */
1104
- /* If seqDef.offset > 3, then this is seqDef.offset - 3
1105
- * If seqDef.offset < 3, then this is the corresponding repeat offset
1106
- * But if seqDef.offset < 3 and litLength == 0, this is the
1107
- * repeat offset before the corresponding repeat offset
1108
- * And if seqDef.offset == 3 and litLength == 0, this is the
1109
- * most recent repeat offset - 1
1110
- */
1111
- unsigned int offset;
1112
- unsigned int litLength; /* Literal length */
1113
- unsigned int matchLength; /* Match length */
1114
- /* 0 when seq not rep and seqDef.offset otherwise
1115
- * when litLength == 0 this will be <= 4, otherwise <= 3 like normal
1116
- */
1117
- unsigned int rep;
1169
+ unsigned int offset; /* The offset of the match. (NOT the same as the offset code)
1170
+ * If offset == 0 and matchLength == 0, this sequence represents the last
1171
+ * literals in the block of litLength size.
1172
+ */
1173
+
1174
+ unsigned int litLength; /* Literal length of the sequence. */
1175
+ unsigned int matchLength; /* Match length of the sequence. */
1176
+
1177
+ /* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
1178
+ * In this case, we will treat the sequence as a marker for a block boundary.
1179
+ */
1180
+
1181
+ unsigned int rep; /* Represents which repeat offset is represented by the field 'offset'.
1182
+ * Ranges from [0, 3].
1183
+ *
1184
+ * Repeat offsets are essentially previous offsets from previous sequences sorted in
1185
+ * recency order. For more detail, see doc/zstd_compression_format.md
1186
+ *
1187
+ * If rep == 0, then 'offset' does not contain a repeat offset.
1188
+ * If rep > 0:
1189
+ * If litLength != 0:
1190
+ * rep == 1 --> offset == repeat_offset_1
1191
+ * rep == 2 --> offset == repeat_offset_2
1192
+ * rep == 3 --> offset == repeat_offset_3
1193
+ * If litLength == 0:
1194
+ * rep == 1 --> offset == repeat_offset_2
1195
+ * rep == 2 --> offset == repeat_offset_3
1196
+ * rep == 3 --> offset == repeat_offset_1 - 1
1197
+ *
1198
+ * Note: This field is optional. ZSTD_generateSequences() will calculate the value of
1199
+ * 'rep', but repeat offsets do not necessarily need to be calculated from an external
1200
+ * sequence provider's perspective. For example, ZSTD_compressSequences() does not
1201
+ * use this 'rep' field at all (as of now).
1202
+ */
1118
1203
  } ZSTD_Sequence;
1119
1204
 
1120
1205
  typedef struct {
@@ -1156,6 +1241,18 @@ typedef enum {
1156
1241
  * Decoder cannot recognise automatically this format, requiring this instruction. */
1157
1242
  } ZSTD_format_e;
1158
1243
 
1244
+ typedef enum {
1245
+ /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
1246
+ ZSTD_d_validateChecksum = 0,
1247
+ ZSTD_d_ignoreChecksum = 1
1248
+ } ZSTD_forceIgnoreChecksum_e;
1249
+
1250
+ typedef enum {
1251
+ /* Note: this enum controls ZSTD_d_refMultipleDDicts */
1252
+ ZSTD_rmd_refSingleDDict = 0,
1253
+ ZSTD_rmd_refMultipleDDicts = 1
1254
+ } ZSTD_refMultipleDDicts_e;
1255
+
1159
1256
  typedef enum {
1160
1257
  /* Note: this enum and the behavior it controls are effectively internal
1161
1258
  * implementation details of the compressor. They are expected to continue
@@ -1204,6 +1301,11 @@ typedef enum {
1204
1301
  ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */
1205
1302
  } ZSTD_literalCompressionMode_e;
1206
1303
 
1304
+ typedef enum {
1305
+ ZSTD_urm_auto = 0, /* Automatically determine whether or not we use row matchfinder */
1306
+ ZSTD_urm_disableRowMatchFinder = 1, /* Never use row matchfinder */
1307
+ ZSTD_urm_enableRowMatchFinder = 2 /* Always use row matchfinder when applicable */
1308
+ } ZSTD_useRowMatchFinderMode_e;
1207
1309
 
1208
1310
  /***************************************
1209
1311
  * Frame size functions
@@ -1237,7 +1339,7 @@ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t
1237
1339
  * `srcSize` must be the _exact_ size of this series
1238
1340
  * (i.e. there should be a frame boundary at `src + srcSize`)
1239
1341
  * @return : - upper-bound for the decompressed size of all data in all successive frames
1240
- * - if an error occured: ZSTD_CONTENTSIZE_ERROR
1342
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
1241
1343
  *
1242
1344
  * note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame.
1243
1345
  * note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`.
@@ -1253,14 +1355,91 @@ ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcS
1253
1355
  * or an error code (if srcSize is too small) */
1254
1356
  ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1255
1357
 
1256
- /*! ZSTD_getSequences() :
1257
- * Extract sequences from the sequence store
1358
+ typedef enum {
1359
+ ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
1360
+ ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
1361
+ } ZSTD_sequenceFormat_e;
1362
+
1363
+ /*! ZSTD_generateSequences() :
1364
+ * Generate sequences using ZSTD_compress2, given a source buffer.
1365
+ *
1366
+ * Each block will end with a dummy sequence
1367
+ * with offset == 0, matchLength == 0, and litLength == length of last literals.
1368
+ * litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
1369
+ * simply acts as a block delimiter.
1370
+ *
1258
1371
  * zc can be used to insert custom compression params.
1259
1372
  * This function invokes ZSTD_compress2
1260
- * @return : number of sequences extracted
1373
+ *
1374
+ * The output of this function can be fed into ZSTD_compressSequences() with CCtx
1375
+ * setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
1376
+ * @return : number of sequences generated
1377
+ */
1378
+
1379
+ ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1380
+ size_t outSeqsSize, const void* src, size_t srcSize);
1381
+
1382
+ /*! ZSTD_mergeBlockDelimiters() :
1383
+ * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
1384
+ * by merging them into into the literals of the next sequence.
1385
+ *
1386
+ * As such, the final generated result has no explicit representation of block boundaries,
1387
+ * and the final last literals segment is not represented in the sequences.
1388
+ *
1389
+ * The output of this function can be fed into ZSTD_compressSequences() with CCtx
1390
+ * setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters
1391
+ * @return : number of sequences left after merging
1392
+ */
1393
+ ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
1394
+
1395
+ /*! ZSTD_compressSequences() :
1396
+ * Compress an array of ZSTD_Sequence, generated from the original source buffer, into dst.
1397
+ * If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
1398
+ * The entire source is compressed into a single frame.
1399
+ *
1400
+ * The compression behavior changes based on cctx params. In particular:
1401
+ * If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain
1402
+ * no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on
1403
+ * the block size derived from the cctx, and sequences may be split. This is the default setting.
1404
+ *
1405
+ * If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
1406
+ * block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
1407
+ *
1408
+ * If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
1409
+ * behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
1410
+ * specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
1411
+ *
1412
+ * In addition to the two adjustable experimental params, there are other important cctx params.
1413
+ * - 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.
1414
+ * - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression.
1415
+ * - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
1416
+ * is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
1417
+ *
1418
+ * Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
1419
+ * Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
1420
+ * and cannot emit an RLE block that disagrees with the repcode history
1421
+ * @return : final compressed size or a ZSTD error.
1261
1422
  */
1262
- ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1263
- size_t outSeqsSize, const void* src, size_t srcSize);
1423
+ ZSTDLIB_API size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
1424
+ const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
1425
+ const void* src, size_t srcSize);
1426
+
1427
+
1428
+ /*! ZSTD_writeSkippableFrame() :
1429
+ * Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
1430
+ *
1431
+ * Skippable frames begin with a a 4-byte magic number. There are 16 possible choices of magic number,
1432
+ * ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
1433
+ * As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
1434
+ * the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1435
+ *
1436
+ * Returns an error if destination buffer is not large enough, if the source size is not representable
1437
+ * with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
1438
+ *
1439
+ * @return : number of bytes written or a ZSTD error.
1440
+ */
1441
+ ZSTDLIB_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
1442
+ const void* src, size_t srcSize, unsigned magicVariant);
1264
1443
 
1265
1444
 
1266
1445
  /***************************************
@@ -1372,7 +1551,11 @@ ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
1372
1551
  typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
1373
1552
  typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
1374
1553
  typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
1375
- static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
1554
+ static
1555
+ #ifdef __GNUC__
1556
+ __attribute__((__unused__))
1557
+ #endif
1558
+ ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
1376
1559
 
1377
1560
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1378
1561
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
@@ -1385,12 +1568,38 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictS
1385
1568
  ZSTD_compressionParameters cParams,
1386
1569
  ZSTD_customMem customMem);
1387
1570
 
1388
- ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
1389
- ZSTD_dictLoadMethod_e dictLoadMethod,
1390
- ZSTD_dictContentType_e dictContentType,
1391
- ZSTD_customMem customMem);
1571
+ /* ! Thread pool :
1572
+ * These prototypes make it possible to share a thread pool among multiple compression contexts.
1573
+ * This can limit resources for applications with multiple threads where each one uses
1574
+ * a threaded compression mode (via ZSTD_c_nbWorkers parameter).
1575
+ * ZSTD_createThreadPool creates a new thread pool with a given number of threads.
1576
+ * Note that the lifetime of such pool must exist while being used.
1577
+ * ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
1578
+ * to use an internal thread pool).
1579
+ * ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer.
1580
+ */
1581
+ typedef struct POOL_ctx_s ZSTD_threadPool;
1582
+ ZSTDLIB_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
1583
+ ZSTDLIB_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */
1584
+ ZSTDLIB_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
1392
1585
 
1393
1586
 
1587
+ /*
1588
+ * This API is temporary and is expected to change or disappear in the future!
1589
+ */
1590
+ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced2(
1591
+ const void* dict, size_t dictSize,
1592
+ ZSTD_dictLoadMethod_e dictLoadMethod,
1593
+ ZSTD_dictContentType_e dictContentType,
1594
+ const ZSTD_CCtx_params* cctxParams,
1595
+ ZSTD_customMem customMem);
1596
+
1597
+ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(
1598
+ const void* dict, size_t dictSize,
1599
+ ZSTD_dictLoadMethod_e dictLoadMethod,
1600
+ ZSTD_dictContentType_e dictContentType,
1601
+ ZSTD_customMem customMem);
1602
+
1394
1603
 
1395
1604
  /***************************************
1396
1605
  * Advanced compression functions
@@ -1430,18 +1639,20 @@ ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParame
1430
1639
  /*! ZSTD_compress_advanced() :
1431
1640
  * Note : this function is now DEPRECATED.
1432
1641
  * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters.
1433
- * This prototype will be marked as deprecated and generate compilation warning on reaching v1.5.x */
1434
- ZSTDLIB_API size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
1642
+ * This prototype will generate compilation warnings. */
1643
+ ZSTD_DEPRECATED("use ZSTD_compress2")
1644
+ size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
1435
1645
  void* dst, size_t dstCapacity,
1436
1646
  const void* src, size_t srcSize,
1437
1647
  const void* dict,size_t dictSize,
1438
1648
  ZSTD_parameters params);
1439
1649
 
1440
1650
  /*! ZSTD_compress_usingCDict_advanced() :
1441
- * Note : this function is now REDUNDANT.
1651
+ * Note : this function is now DEPRECATED.
1442
1652
  * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters.
1443
- * This prototype will be marked as deprecated and generate compilation warning in some future version */
1444
- ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
1653
+ * This prototype will generate compilation warnings. */
1654
+ ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary")
1655
+ size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
1445
1656
  void* dst, size_t dstCapacity,
1446
1657
  const void* src, size_t srcSize,
1447
1658
  const ZSTD_CDict* cdict,
@@ -1503,7 +1714,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
1503
1714
 
1504
1715
  /* Controls how the literals are compressed (default is auto).
1505
1716
  * The value must be of type ZSTD_literalCompressionMode_e.
1506
- * See ZSTD_literalCompressionMode_t enum definition for details.
1717
+ * See ZSTD_literalCompressionMode_e enum definition for details.
1507
1718
  */
1508
1719
  #define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
1509
1720
 
@@ -1518,12 +1729,189 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
1518
1729
  * but compression ratio may regress significantly if guess considerably underestimates */
1519
1730
  #define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
1520
1731
 
1732
+ /* Controls whether the new and experimental "dedicated dictionary search
1733
+ * structure" can be used. This feature is still rough around the edges, be
1734
+ * prepared for surprising behavior!
1735
+ *
1736
+ * How to use it:
1737
+ *
1738
+ * When using a CDict, whether to use this feature or not is controlled at
1739
+ * CDict creation, and it must be set in a CCtxParams set passed into that
1740
+ * construction (via ZSTD_createCDict_advanced2()). A compression will then
1741
+ * use the feature or not based on how the CDict was constructed; the value of
1742
+ * this param, set in the CCtx, will have no effect.
1743
+ *
1744
+ * However, when a dictionary buffer is passed into a CCtx, such as via
1745
+ * ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control
1746
+ * whether the CDict that is created internally can use the feature or not.
1747
+ *
1748
+ * What it does:
1749
+ *
1750
+ * Normally, the internal data structures of the CDict are analogous to what
1751
+ * would be stored in a CCtx after compressing the contents of a dictionary.
1752
+ * To an approximation, a compression using a dictionary can then use those
1753
+ * data structures to simply continue what is effectively a streaming
1754
+ * compression where the simulated compression of the dictionary left off.
1755
+ * Which is to say, the search structures in the CDict are normally the same
1756
+ * format as in the CCtx.
1757
+ *
1758
+ * It is possible to do better, since the CDict is not like a CCtx: the search
1759
+ * structures are written once during CDict creation, and then are only read
1760
+ * after that, while the search structures in the CCtx are both read and
1761
+ * written as the compression goes along. This means we can choose a search
1762
+ * structure for the dictionary that is read-optimized.
1763
+ *
1764
+ * This feature enables the use of that different structure.
1765
+ *
1766
+ * Note that some of the members of the ZSTD_compressionParameters struct have
1767
+ * different semantics and constraints in the dedicated search structure. It is
1768
+ * highly recommended that you simply set a compression level in the CCtxParams
1769
+ * you pass into the CDict creation call, and avoid messing with the cParams
1770
+ * directly.
1771
+ *
1772
+ * Effects:
1773
+ *
1774
+ * This will only have any effect when the selected ZSTD_strategy
1775
+ * implementation supports this feature. Currently, that's limited to
1776
+ * ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2.
1777
+ *
1778
+ * Note that this means that the CDict tables can no longer be copied into the
1779
+ * CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be
1780
+ * useable. The dictionary can only be attached or reloaded.
1781
+ *
1782
+ * In general, you should expect compression to be faster--sometimes very much
1783
+ * so--and CDict creation to be slightly slower. Eventually, we will probably
1784
+ * make this mode the default.
1785
+ */
1786
+ #define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8
1787
+
1788
+ /* ZSTD_c_stableInBuffer
1789
+ * Experimental parameter.
1790
+ * Default is 0 == disabled. Set to 1 to enable.
1791
+ *
1792
+ * Tells the compressor that the ZSTD_inBuffer will ALWAYS be the same
1793
+ * between calls, except for the modifications that zstd makes to pos (the
1794
+ * caller must not modify pos). This is checked by the compressor, and
1795
+ * compression will fail if it ever changes. This means the only flush
1796
+ * mode that makes sense is ZSTD_e_end, so zstd will error if ZSTD_e_end
1797
+ * is not used. The data in the ZSTD_inBuffer in the range [src, src + pos)
1798
+ * MUST not be modified during compression or you will get data corruption.
1799
+ *
1800
+ * When this flag is enabled zstd won't allocate an input window buffer,
1801
+ * because the user guarantees it can reference the ZSTD_inBuffer until
1802
+ * the frame is complete. But, it will still allocate an output buffer
1803
+ * large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also
1804
+ * avoid the memcpy() from the input buffer to the input window buffer.
1805
+ *
1806
+ * NOTE: ZSTD_compressStream2() will error if ZSTD_e_end is not used.
1807
+ * That means this flag cannot be used with ZSTD_compressStream().
1808
+ *
1809
+ * NOTE: So long as the ZSTD_inBuffer always points to valid memory, using
1810
+ * this flag is ALWAYS memory safe, and will never access out-of-bounds
1811
+ * memory. However, compression WILL fail if you violate the preconditions.
1812
+ *
1813
+ * WARNING: The data in the ZSTD_inBuffer in the range [dst, dst + pos) MUST
1814
+ * not be modified during compression or you will get data corruption. This
1815
+ * is because zstd needs to reference data in the ZSTD_inBuffer to find
1816
+ * matches. Normally zstd maintains its own window buffer for this purpose,
1817
+ * but passing this flag tells zstd to use the user provided buffer.
1818
+ */
1819
+ #define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9
1820
+
1821
+ /* ZSTD_c_stableOutBuffer
1822
+ * Experimental parameter.
1823
+ * Default is 0 == disabled. Set to 1 to enable.
1824
+ *
1825
+ * Tells he compressor that the ZSTD_outBuffer will not be resized between
1826
+ * calls. Specifically: (out.size - out.pos) will never grow. This gives the
1827
+ * compressor the freedom to say: If the compressed data doesn't fit in the
1828
+ * output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to
1829
+ * always decompress directly into the output buffer, instead of decompressing
1830
+ * into an internal buffer and copying to the output buffer.
1831
+ *
1832
+ * When this flag is enabled zstd won't allocate an output buffer, because
1833
+ * it can write directly to the ZSTD_outBuffer. It will still allocate the
1834
+ * input window buffer (see ZSTD_c_stableInBuffer).
1835
+ *
1836
+ * Zstd will check that (out.size - out.pos) never grows and return an error
1837
+ * if it does. While not strictly necessary, this should prevent surprises.
1838
+ */
1839
+ #define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
1840
+
1841
+ /* ZSTD_c_blockDelimiters
1842
+ * Default is 0 == ZSTD_sf_noBlockDelimiters.
1843
+ *
1844
+ * For use with sequence compression API: ZSTD_compressSequences().
1845
+ *
1846
+ * Designates whether or not the given array of ZSTD_Sequence contains block delimiters
1847
+ * and last literals, which are defined as sequences with offset == 0 and matchLength == 0.
1848
+ * See the definition of ZSTD_Sequence for more specifics.
1849
+ */
1850
+ #define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
1851
+
1852
+ /* ZSTD_c_validateSequences
1853
+ * Default is 0 == disabled. Set to 1 to enable sequence validation.
1854
+ *
1855
+ * For use with sequence compression API: ZSTD_compressSequences().
1856
+ * Designates whether or not we validate sequences provided to ZSTD_compressSequences()
1857
+ * during function execution.
1858
+ *
1859
+ * Without validation, providing a sequence that does not conform to the zstd spec will cause
1860
+ * undefined behavior, and may produce a corrupted block.
1861
+ *
1862
+ * With validation enabled, a if sequence is invalid (see doc/zstd_compression_format.md for
1863
+ * specifics regarding offset/matchlength requirements) then the function will bail out and
1864
+ * return an error.
1865
+ *
1866
+ */
1867
+ #define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
1868
+
1869
+ /* ZSTD_c_splitBlocks
1870
+ * Default is 0 == disabled. Set to 1 to enable block splitting.
1871
+ *
1872
+ * Will attempt to split blocks in order to improve compression ratio at the cost of speed.
1873
+ */
1874
+ #define ZSTD_c_splitBlocks ZSTD_c_experimentalParam13
1875
+
1876
+ /* ZSTD_c_useRowMatchFinder
1877
+ * Default is ZSTD_urm_auto.
1878
+ * Controlled with ZSTD_useRowMatchFinderMode_e enum.
1879
+ *
1880
+ * By default, in ZSTD_urm_auto, when finalizing the compression parameters, the library
1881
+ * will decide at runtime whether to use the row-based matchfinder based on support for SIMD
1882
+ * instructions as well as the windowLog.
1883
+ *
1884
+ * Set to ZSTD_urm_disableRowMatchFinder to never use row-based matchfinder.
1885
+ * Set to ZSTD_urm_enableRowMatchFinder to force usage of row-based matchfinder.
1886
+ */
1887
+ #define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14
1888
+
1889
+ /* ZSTD_c_deterministicRefPrefix
1890
+ * Default is 0 == disabled. Set to 1 to enable.
1891
+ *
1892
+ * Zstd produces different results for prefix compression when the prefix is
1893
+ * directly adjacent to the data about to be compressed vs. when it isn't.
1894
+ * This is because zstd detects that the two buffers are contiguous and it can
1895
+ * use a more efficient match finding algorithm. However, this produces different
1896
+ * results than when the two buffers are non-contiguous. This flag forces zstd
1897
+ * to always load the prefix in non-contiguous mode, even if it happens to be
1898
+ * adjacent to the data, to guarantee determinism.
1899
+ *
1900
+ * If you really care about determinism when using a dictionary or prefix,
1901
+ * like when doing delta compression, you should select this option. It comes
1902
+ * at a speed penalty of about ~2.5% if the dictionary and data happened to be
1903
+ * contiguous, and is free if they weren't contiguous. We don't expect that
1904
+ * intentionally making the dictionary and data contiguous will be worth the
1905
+ * cost to memcpy() the data.
1906
+ */
1907
+ #define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
1908
+
1521
1909
  /*! ZSTD_CCtx_getParameter() :
1522
1910
  * Get the requested compression parameter value, selected by enum ZSTD_cParameter,
1523
1911
  * and store it into int* value.
1524
1912
  * @return : 0, or an error code (which can be tested with ZSTD_isError()).
1525
1913
  */
1526
- ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
1914
+ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
1527
1915
 
1528
1916
 
1529
1917
  /*! ZSTD_CCtx_params :
@@ -1538,13 +1926,13 @@ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param
1538
1926
  * These parameters will be applied to
1539
1927
  * all subsequent frames.
1540
1928
  * - ZSTD_compressStream2() : Do compression using the CCtx.
1541
- * - ZSTD_freeCCtxParams() : Free the memory.
1929
+ * - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer.
1542
1930
  *
1543
1931
  * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
1544
1932
  * for static allocation of CCtx for single-threaded compression.
1545
1933
  */
1546
1934
  ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
1547
- ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
1935
+ ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */
1548
1936
 
1549
1937
  /*! ZSTD_CCtxParams_reset() :
1550
1938
  * Reset params to default values.
@@ -1563,11 +1951,13 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compre
1563
1951
  */
1564
1952
  ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
1565
1953
 
1566
- /*! ZSTD_CCtxParams_setParameter() :
1954
+ /*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+
1567
1955
  * Similar to ZSTD_CCtx_setParameter.
1568
1956
  * Set one compression parameter, selected by enum ZSTD_cParameter.
1569
- * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams().
1570
- * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1957
+ * Parameters must be applied to a ZSTD_CCtx using
1958
+ * ZSTD_CCtx_setParametersUsingCCtxParams().
1959
+ * @result : a code representing success or failure (which can be tested with
1960
+ * ZSTD_isError()).
1571
1961
  */
1572
1962
  ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
1573
1963
 
@@ -1576,7 +1966,7 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_c
1576
1966
  * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
1577
1967
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1578
1968
  */
1579
- ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
1969
+ ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
1580
1970
 
1581
1971
  /*! ZSTD_CCtx_setParametersUsingCCtxParams() :
1582
1972
  * Apply a set of ZSTD_CCtx_params to the compression context.
@@ -1647,6 +2037,13 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* pre
1647
2037
  */
1648
2038
  ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
1649
2039
 
2040
+ /*! ZSTD_DCtx_getParameter() :
2041
+ * Get the requested decompression parameter value, selected by enum ZSTD_dParameter,
2042
+ * and store it into int* value.
2043
+ * @return : 0, or an error code (which can be tested with ZSTD_isError()).
2044
+ */
2045
+ ZSTDLIB_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
2046
+
1650
2047
  /* ZSTD_d_format
1651
2048
  * experimental parameter,
1652
2049
  * allowing selection between ZSTD_format_e input compression formats
@@ -1684,12 +2081,49 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
1684
2081
  */
1685
2082
  #define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
1686
2083
 
2084
+ /* ZSTD_d_forceIgnoreChecksum
2085
+ * Experimental parameter.
2086
+ * Default is 0 == disabled. Set to 1 to enable
2087
+ *
2088
+ * Tells the decompressor to skip checksum validation during decompression, regardless
2089
+ * of whether checksumming was specified during compression. This offers some
2090
+ * slight performance benefits, and may be useful for debugging.
2091
+ * Param has values of type ZSTD_forceIgnoreChecksum_e
2092
+ */
2093
+ #define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
2094
+
2095
+ /* ZSTD_d_refMultipleDDicts
2096
+ * Experimental parameter.
2097
+ * Default is 0 == disabled. Set to 1 to enable
2098
+ *
2099
+ * If enabled and dctx is allocated on the heap, then additional memory will be allocated
2100
+ * to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
2101
+ * using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
2102
+ * store all references. At decompression time, the appropriate dictID is selected
2103
+ * from the set of DDicts based on the dictID in the frame.
2104
+ *
2105
+ * Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
2106
+ *
2107
+ * Param has values of byte ZSTD_refMultipleDDicts_e
2108
+ *
2109
+ * WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory
2110
+ * allocation for the hash table. ZSTD_freeDCtx() also frees this memory.
2111
+ * Memory is allocated as per ZSTD_DCtx::customMem.
2112
+ *
2113
+ * Although this function allocates memory for the table, the user is still responsible for
2114
+ * memory management of the underlying ZSTD_DDict* themselves.
2115
+ */
2116
+ #define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4
2117
+
2118
+
1687
2119
  /*! ZSTD_DCtx_setFormat() :
2120
+ * This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter().
1688
2121
  * Instruct the decoder context about what kind of data to decode next.
1689
2122
  * This instruction is mandatory to decode data without a fully-formed header,
1690
2123
  * such ZSTD_f_zstd1_magicless for example.
1691
2124
  * @return : 0, or an error code (which can be tested using ZSTD_isError()). */
1692
- ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
2125
+ ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
2126
+ size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
1693
2127
 
1694
2128
  /*! ZSTD_decompressStream_simpleArgs() :
1695
2129
  * Same as ZSTD_decompressStream(),
@@ -1711,8 +2145,9 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
1711
2145
  ********************************************************************/
1712
2146
 
1713
2147
  /*===== Advanced Streaming compression functions =====*/
1714
- /**! ZSTD_initCStream_srcSize() :
1715
- * This function is deprecated, and equivalent to:
2148
+
2149
+ /*! ZSTD_initCStream_srcSize() :
2150
+ * This function is DEPRECATED, and equivalent to:
1716
2151
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1717
2152
  * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
1718
2153
  * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
@@ -1721,15 +2156,15 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
1721
2156
  * pledgedSrcSize must be correct. If it is not known at init time, use
1722
2157
  * ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs,
1723
2158
  * "0" also disables frame content size field. It may be enabled in the future.
1724
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2159
+ * This prototype will generate compilation warnings.
1725
2160
  */
1726
- ZSTDLIB_API size_t
1727
- ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
2161
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2162
+ size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
1728
2163
  int compressionLevel,
1729
2164
  unsigned long long pledgedSrcSize);
1730
2165
 
1731
- /**! ZSTD_initCStream_usingDict() :
1732
- * This function is deprecated, and is equivalent to:
2166
+ /*! ZSTD_initCStream_usingDict() :
2167
+ * This function is DEPRECATED, and is equivalent to:
1733
2168
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1734
2169
  * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
1735
2170
  * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize);
@@ -1738,15 +2173,15 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
1738
2173
  * dict == NULL or dictSize < 8, in which case no dict is used.
1739
2174
  * Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if
1740
2175
  * it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.
1741
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2176
+ * This prototype will generate compilation warnings.
1742
2177
  */
1743
- ZSTDLIB_API size_t
1744
- ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
2178
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2179
+ size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
1745
2180
  const void* dict, size_t dictSize,
1746
2181
  int compressionLevel);
1747
2182
 
1748
- /**! ZSTD_initCStream_advanced() :
1749
- * This function is deprecated, and is approximately equivalent to:
2183
+ /*! ZSTD_initCStream_advanced() :
2184
+ * This function is DEPRECATED, and is approximately equivalent to:
1750
2185
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1751
2186
  * // Pseudocode: Set each zstd parameter and leave the rest as-is.
1752
2187
  * for ((param, value) : params) {
@@ -1758,25 +2193,26 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
1758
2193
  * dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy.
1759
2194
  * pledgedSrcSize must be correct.
1760
2195
  * If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN.
1761
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2196
+ * This prototype will generate compilation warnings.
1762
2197
  */
1763
- ZSTDLIB_API size_t
1764
- ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
2198
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2199
+ size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
1765
2200
  const void* dict, size_t dictSize,
1766
2201
  ZSTD_parameters params,
1767
2202
  unsigned long long pledgedSrcSize);
1768
2203
 
1769
- /**! ZSTD_initCStream_usingCDict() :
1770
- * This function is deprecated, and equivalent to:
2204
+ /*! ZSTD_initCStream_usingCDict() :
2205
+ * This function is DEPRECATED, and equivalent to:
1771
2206
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1772
2207
  * ZSTD_CCtx_refCDict(zcs, cdict);
1773
- *
2208
+ *
1774
2209
  * note : cdict will just be referenced, and must outlive compression session
1775
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2210
+ * This prototype will generate compilation warnings.
1776
2211
  */
1777
- ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
2212
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2213
+ size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
1778
2214
 
1779
- /**! ZSTD_initCStream_usingCDict_advanced() :
2215
+ /*! ZSTD_initCStream_usingCDict_advanced() :
1780
2216
  * This function is DEPRECATED, and is approximately equivalent to:
1781
2217
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1782
2218
  * // Pseudocode: Set each zstd frame parameter and leave the rest as-is.
@@ -1789,18 +2225,21 @@ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDi
1789
2225
  * same as ZSTD_initCStream_usingCDict(), with control over frame parameters.
1790
2226
  * pledgedSrcSize must be correct. If srcSize is not known at init time, use
1791
2227
  * value ZSTD_CONTENTSIZE_UNKNOWN.
1792
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2228
+ * This prototype will generate compilation warnings.
1793
2229
  */
1794
- ZSTDLIB_API size_t
1795
- ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
2230
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2231
+ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
1796
2232
  const ZSTD_CDict* cdict,
1797
2233
  ZSTD_frameParameters fParams,
1798
2234
  unsigned long long pledgedSrcSize);
1799
2235
 
1800
2236
  /*! ZSTD_resetCStream() :
1801
- * This function is deprecated, and is equivalent to:
2237
+ * This function is DEPRECATED, and is equivalent to:
1802
2238
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1803
2239
  * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
2240
+ * Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but
2241
+ * ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be
2242
+ * explicitly specified.
1804
2243
  *
1805
2244
  * start a new frame, using same parameters from previous frame.
1806
2245
  * This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
@@ -1810,9 +2249,10 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
1810
2249
  * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
1811
2250
  * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
1812
2251
  * @return : 0, or an error code (which can be tested using ZSTD_isError())
1813
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2252
+ * This prototype will generate compilation warnings.
1814
2253
  */
1815
- ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
2254
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2255
+ size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
1816
2256
 
1817
2257
 
1818
2258
  typedef struct {
@@ -1849,7 +2289,8 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
1849
2289
 
1850
2290
 
1851
2291
  /*===== Advanced Streaming decompression functions =====*/
1852
- /**
2292
+
2293
+ /*!
1853
2294
  * This function is deprecated, and is equivalent to:
1854
2295
  *
1855
2296
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1860,7 +2301,7 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
1860
2301
  */
1861
2302
  ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
1862
2303
 
1863
- /**
2304
+ /*!
1864
2305
  * This function is deprecated, and is equivalent to:
1865
2306
  *
1866
2307
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1871,7 +2312,7 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dic
1871
2312
  */
1872
2313
  ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
1873
2314
 
1874
- /**
2315
+ /*!
1875
2316
  * This function is deprecated, and is equivalent to:
1876
2317
  *
1877
2318
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1898,8 +2339,7 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
1898
2339
  ZSTD_CCtx object can be re-used multiple times within successive compression operations.
1899
2340
 
1900
2341
  Start by initializing a context.
1901
- Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
1902
- or ZSTD_compressBegin_advanced(), for finer parameter control.
2342
+ Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
1903
2343
  It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
1904
2344
 
1905
2345
  Then, consume your input using ZSTD_compressContinue().
@@ -1924,16 +2364,18 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
1924
2364
  /*===== Buffer-less streaming compression functions =====*/
1925
2365
  ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
1926
2366
  ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
1927
- ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
1928
2367
  ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
1929
- 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 must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
1930
2368
  ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
1931
2369
 
1932
2370
  ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1933
2371
  ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1934
2372
 
1935
-
1936
- /*-
2373
+ /* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */
2374
+ ZSTD_DEPRECATED("use advanced API to access custom parameters")
2375
+ size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
2376
+ ZSTD_DEPRECATED("use advanced API to access custom parameters")
2377
+ 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 must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
2378
+ /**
1937
2379
  Buffer-less streaming decompression (synchronous mode)
1938
2380
 
1939
2381
  A ZSTD_DCtx object is required to track streaming operations.