zstdlib 0.12.0-arm64-darwin → 0.13.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +7 -0
  3. data/Rakefile +1 -1
  4. data/ext/zstdlib_c/extconf.rb +1 -1
  5. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/allocations.h +1 -1
  6. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/bitstream.h +49 -29
  7. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/compiler.h +114 -22
  8. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/cpu.h +36 -0
  9. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/debug.c +6 -0
  10. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/debug.h +20 -11
  11. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/error_private.h +45 -36
  12. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/fse.h +3 -2
  13. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/fse_decompress.c +19 -17
  14. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/huf.h +14 -1
  15. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/mem.h +0 -9
  16. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/pool.c +1 -1
  17. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/pool.h +1 -1
  18. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/portability_macros.h +2 -0
  19. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/threading.c +8 -2
  20. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/xxhash.c +5 -11
  21. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/xxhash.h +2341 -1007
  22. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_internal.h +5 -5
  23. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/fse_compress.c +8 -7
  24. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/huf_compress.c +54 -25
  25. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress.c +282 -161
  26. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_internal.h +29 -27
  27. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_superblock.c +224 -113
  28. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_cwksp.h +19 -13
  29. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_double_fast.c +17 -5
  30. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_double_fast.h +11 -0
  31. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_fast.c +14 -6
  32. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_lazy.c +129 -87
  33. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_lazy.h +103 -28
  34. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm.c +8 -2
  35. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_opt.c +216 -112
  36. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_opt.h +31 -7
  37. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstdmt_compress.c +94 -79
  38. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/huf_decompress.c +188 -126
  39. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/huf_decompress_amd64.S +38 -19
  40. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress.c +84 -32
  41. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_block.c +231 -208
  42. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_block.h +1 -1
  43. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_decompress_internal.h +2 -0
  44. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zstd.h +129 -60
  45. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzclose.c +1 -3
  46. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzlib.c +20 -73
  47. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzread.c +17 -58
  48. data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzwrite.c +18 -58
  49. data/lib/2.4/zstdlib_c.bundle +0 -0
  50. data/lib/2.5/zstdlib_c.bundle +0 -0
  51. data/lib/2.6/zstdlib_c.bundle +0 -0
  52. data/lib/2.7/zstdlib_c.bundle +0 -0
  53. data/lib/3.0/zstdlib_c.bundle +0 -0
  54. data/lib/3.1/zstdlib_c.bundle +0 -0
  55. data/lib/3.2/zstdlib_c.bundle +0 -0
  56. data/lib/3.3/zstdlib_c.bundle +0 -0
  57. metadata +75 -75
  58. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/bits.h +0 -0
  59. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/entropy_common.c +0 -0
  60. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/error_private.c +0 -0
  61. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/threading.h +0 -0
  62. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_common.c +0 -0
  63. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_deps.h +0 -0
  64. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/common/zstd_trace.h +0 -0
  65. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/clevels.h +0 -0
  66. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/hist.c +0 -0
  67. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/hist.h +0 -0
  68. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_literals.c +0 -0
  69. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_literals.h +0 -0
  70. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_sequences.c +0 -0
  71. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_sequences.h +0 -0
  72. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_compress_superblock.h +0 -0
  73. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_fast.h +0 -0
  74. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm.h +0 -0
  75. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstd_ldm_geartab.h +0 -0
  76. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/compress/zstdmt_compress.h +0 -0
  77. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_ddict.c +0 -0
  78. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/decompress/zstd_ddict.h +0 -0
  79. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zdict.h +0 -0
  80. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/lib/zstd_errors.h +0 -0
  81. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzcompatibility.h +0 -0
  82. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/gzguts.h +0 -0
  83. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/zstd_zlibwrapper.c +0 -0
  84. /data/ext/zstdlib_c/{zstd-1.5.5 → zstd-1.5.6}/zlibWrapper/zstd_zlibwrapper.h +0 -0
@@ -47,7 +47,7 @@ typedef enum {
47
47
  */
48
48
  size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
49
49
  void* dst, size_t dstCapacity,
50
- const void* src, size_t srcSize, const int frame, const streaming_operation streaming);
50
+ const void* src, size_t srcSize, const streaming_operation streaming);
51
51
 
52
52
  /* ZSTD_buildFSETable() :
53
53
  * generate FSE decoding table for one symbol (ll, ml or off)
@@ -153,6 +153,7 @@ struct ZSTD_DCtx_s
153
153
  size_t litSize;
154
154
  size_t rleSize;
155
155
  size_t staticSize;
156
+ int isFrameDecompression;
156
157
  #if DYNAMIC_BMI2 != 0
157
158
  int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
158
159
  #endif
@@ -166,6 +167,7 @@ struct ZSTD_DCtx_s
166
167
  ZSTD_DDictHashSet* ddictSet; /* Hash set for multiple ddicts */
167
168
  ZSTD_refMultipleDDicts_e refMultipleDDicts; /* User specified: if == 1, will allow references to multiple DDicts. Default == 0 (disabled) */
168
169
  int disableHufAsm;
170
+ int maxBlockSizeParam;
169
171
 
170
172
  /* streaming */
171
173
  ZSTD_dStreamStage streamStage;
@@ -106,7 +106,7 @@ extern "C" {
106
106
  /*------ Version ------*/
107
107
  #define ZSTD_VERSION_MAJOR 1
108
108
  #define ZSTD_VERSION_MINOR 5
109
- #define ZSTD_VERSION_RELEASE 5
109
+ #define ZSTD_VERSION_RELEASE 6
110
110
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
111
111
 
112
112
  /*! ZSTD_versionNumber() :
@@ -228,7 +228,7 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
228
228
  * for example to size a static array on stack.
229
229
  * Will produce constant value 0 if srcSize too large.
230
230
  */
231
- #define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00LLU : 0xFF00FF00U)
231
+ #define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
232
232
  #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
233
  ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
234
234
  /* ZSTD_isError() :
@@ -249,7 +249,7 @@ ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compres
249
249
  /*= Compression context
250
250
  * When compressing many times,
251
251
  * it is recommended to allocate a context just once,
252
- * and re-use it for each successive compression operation.
252
+ * and reuse it for each successive compression operation.
253
253
  * This will make workload friendlier for system's memory.
254
254
  * Note : re-using context is just a speed / resource optimization.
255
255
  * It doesn't change the compression ratio, which remains identical.
@@ -262,9 +262,9 @@ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer *
262
262
 
263
263
  /*! ZSTD_compressCCtx() :
264
264
  * Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
265
- * Important : in order to behave similarly to `ZSTD_compress()`,
266
- * this function compresses at requested compression level,
267
- * __ignoring any other parameter__ .
265
+ * Important : in order to mirror `ZSTD_compress()` behavior,
266
+ * this function compresses at the requested compression level,
267
+ * __ignoring any other advanced parameter__ .
268
268
  * If any advanced parameter was set using the advanced API,
269
269
  * they will all be reset. Only `compressionLevel` remains.
270
270
  */
@@ -276,7 +276,7 @@ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
276
276
  /*= Decompression context
277
277
  * When decompressing many times,
278
278
  * it is recommended to allocate a context only once,
279
- * and re-use it for each successive compression operation.
279
+ * and reuse it for each successive compression operation.
280
280
  * This will make workload friendlier for system's memory.
281
281
  * Use one context per thread for parallel execution. */
282
282
  typedef struct ZSTD_DCtx_s ZSTD_DCtx;
@@ -286,7 +286,7 @@ ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer *
286
286
  /*! ZSTD_decompressDCtx() :
287
287
  * Same as ZSTD_decompress(),
288
288
  * requires an allocated ZSTD_DCtx.
289
- * Compatible with sticky parameters.
289
+ * Compatible with sticky parameters (see below).
290
290
  */
291
291
  ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
292
292
  void* dst, size_t dstCapacity,
@@ -302,12 +302,12 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
302
302
  * using ZSTD_CCtx_set*() functions.
303
303
  * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame.
304
304
  * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` !
305
- * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ .
305
+ * __They do not apply to one-shot variants such as ZSTD_compressCCtx()__ .
306
306
  *
307
307
  * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
308
308
  *
309
309
  * This API supersedes all other "advanced" API entry points in the experimental section.
310
- * In the future, we expect to remove from experimental API entry points which are redundant with this API.
310
+ * In the future, we expect to remove API entry points from experimental which are redundant with this API.
311
311
  */
312
312
 
313
313
 
@@ -390,6 +390,19 @@ typedef enum {
390
390
  * The higher the value of selected strategy, the more complex it is,
391
391
  * resulting in stronger and slower compression.
392
392
  * Special: value 0 means "use default strategy". */
393
+
394
+ ZSTD_c_targetCBlockSize=130, /* v1.5.6+
395
+ * Attempts to fit compressed block size into approximatively targetCBlockSize.
396
+ * Bound by ZSTD_TARGETCBLOCKSIZE_MIN and ZSTD_TARGETCBLOCKSIZE_MAX.
397
+ * Note that it's not a guarantee, just a convergence target (default:0).
398
+ * No target when targetCBlockSize == 0.
399
+ * This is helpful in low bandwidth streaming environments to improve end-to-end latency,
400
+ * when a client can make use of partial documents (a prominent example being Chrome).
401
+ * Note: this parameter is stable since v1.5.6.
402
+ * It was present as an experimental parameter in earlier versions,
403
+ * but it's not recommended using it with earlier library versions
404
+ * due to massive performance regressions.
405
+ */
393
406
  /* LDM mode parameters */
394
407
  ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
395
408
  * This parameter is designed to improve compression ratio
@@ -469,7 +482,6 @@ typedef enum {
469
482
  * ZSTD_c_forceMaxWindow
470
483
  * ZSTD_c_forceAttachDict
471
484
  * ZSTD_c_literalCompressionMode
472
- * ZSTD_c_targetCBlockSize
473
485
  * ZSTD_c_srcSizeHint
474
486
  * ZSTD_c_enableDedicatedDictSearch
475
487
  * ZSTD_c_stableInBuffer
@@ -490,7 +502,7 @@ typedef enum {
490
502
  ZSTD_c_experimentalParam3=1000,
491
503
  ZSTD_c_experimentalParam4=1001,
492
504
  ZSTD_c_experimentalParam5=1002,
493
- ZSTD_c_experimentalParam6=1003,
505
+ /* was ZSTD_c_experimentalParam6=1003; is now ZSTD_c_targetCBlockSize */
494
506
  ZSTD_c_experimentalParam7=1004,
495
507
  ZSTD_c_experimentalParam8=1005,
496
508
  ZSTD_c_experimentalParam9=1006,
@@ -575,6 +587,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
575
587
 
576
588
  /*! ZSTD_compress2() :
577
589
  * Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.
590
+ * (note that this entry point doesn't even expose a compression level parameter).
578
591
  * ZSTD_compress2() always starts a new frame.
579
592
  * Should cctx hold data from a previously unfinished frame, everything about it is forgotten.
580
593
  * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
@@ -618,6 +631,7 @@ typedef enum {
618
631
  * ZSTD_d_forceIgnoreChecksum
619
632
  * ZSTD_d_refMultipleDDicts
620
633
  * ZSTD_d_disableHuffmanAssembly
634
+ * ZSTD_d_maxBlockSize
621
635
  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
622
636
  * note : never ever use experimentalParam? names directly
623
637
  */
@@ -625,7 +639,8 @@ typedef enum {
625
639
  ZSTD_d_experimentalParam2=1001,
626
640
  ZSTD_d_experimentalParam3=1002,
627
641
  ZSTD_d_experimentalParam4=1003,
628
- ZSTD_d_experimentalParam5=1004
642
+ ZSTD_d_experimentalParam5=1004,
643
+ ZSTD_d_experimentalParam6=1005
629
644
 
630
645
  } ZSTD_dParameter;
631
646
 
@@ -680,14 +695,14 @@ typedef struct ZSTD_outBuffer_s {
680
695
  * A ZSTD_CStream object is required to track streaming operation.
681
696
  * Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
682
697
  * ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
683
- * It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
698
+ * It is recommended to reuse ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
684
699
  *
685
700
  * For parallel execution, use one separate ZSTD_CStream per thread.
686
701
  *
687
702
  * note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.
688
703
  *
689
704
  * Parameters are sticky : when starting a new compression on the same context,
690
- * it will re-use the same sticky parameters as previous compression session.
705
+ * it will reuse the same sticky parameters as previous compression session.
691
706
  * When in doubt, it's recommended to fully initialize the context before usage.
692
707
  * Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(),
693
708
  * ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to
@@ -776,6 +791,11 @@ typedef enum {
776
791
  * only ZSTD_e_end or ZSTD_e_flush operations are allowed.
777
792
  * Before starting a new compression job, or changing compression parameters,
778
793
  * it is required to fully flush internal buffers.
794
+ * - note: if an operation ends with an error, it may leave @cctx in an undefined state.
795
+ * Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state.
796
+ * In order to be re-employed after an error, a state must be reset,
797
+ * which can be done explicitly (ZSTD_CCtx_reset()),
798
+ * or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())
779
799
  */
780
800
  ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
781
801
  ZSTD_outBuffer* output,
@@ -835,7 +855,7 @@ ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
835
855
  *
836
856
  * A ZSTD_DStream object is required to track streaming operations.
837
857
  * Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
838
- * ZSTD_DStream objects can be re-used multiple times.
858
+ * ZSTD_DStream objects can be reused multiple times.
839
859
  *
840
860
  * Use ZSTD_initDStream() to start a new decompression operation.
841
861
  * @return : recommended first input size
@@ -889,6 +909,12 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
889
909
  * @return : 0 when a frame is completely decoded and fully flushed,
890
910
  * or an error code, which can be tested using ZSTD_isError(),
891
911
  * or any other value > 0, which means there is some decoding or flushing to do to complete current frame.
912
+ *
913
+ * Note: when an operation returns with an error code, the @zds state may be left in undefined state.
914
+ * It's UB to invoke `ZSTD_decompressStream()` on such a state.
915
+ * In order to re-use such a state, it must be first reset,
916
+ * which can be done explicitly (`ZSTD_DCtx_reset()`),
917
+ * or is implied for operations starting some new decompression job (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
892
918
  */
893
919
  ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
894
920
 
@@ -1021,7 +1047,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
1021
1047
  *
1022
1048
  * This API allows dictionaries to be used with ZSTD_compress2(),
1023
1049
  * ZSTD_compressStream2(), and ZSTD_decompressDCtx().
1024
- * Dictionaries are sticky, they remain valid when same context is re-used,
1050
+ * Dictionaries are sticky, they remain valid when same context is reused,
1025
1051
  * they only reset when the context is reset
1026
1052
  * with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters.
1027
1053
  * In contrast, Prefixes are single-use.
@@ -1239,7 +1265,7 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1239
1265
  #define ZSTD_LDM_HASHRATELOG_MAX (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
1240
1266
 
1241
1267
  /* Advanced parameter bounds */
1242
- #define ZSTD_TARGETCBLOCKSIZE_MIN 64
1268
+ #define ZSTD_TARGETCBLOCKSIZE_MIN 1340 /* suitable to fit into an ethernet / wifi / 4G transport frame */
1243
1269
  #define ZSTD_TARGETCBLOCKSIZE_MAX ZSTD_BLOCKSIZE_MAX
1244
1270
  #define ZSTD_SRCSIZEHINT_MIN 0
1245
1271
  #define ZSTD_SRCSIZEHINT_MAX INT_MAX
@@ -1527,25 +1553,38 @@ typedef enum {
1527
1553
  ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
1528
1554
 
1529
1555
  /*! ZSTD_generateSequences() :
1556
+ * WARNING: This function is meant for debugging and informational purposes ONLY!
1557
+ * Its implementation is flawed, and it will be deleted in a future version.
1558
+ * It is not guaranteed to succeed, as there are several cases where it will give
1559
+ * up and fail. You should NOT use this function in production code.
1560
+ *
1561
+ * This function is deprecated, and will be removed in a future version.
1562
+ *
1530
1563
  * Generate sequences using ZSTD_compress2(), given a source buffer.
1531
1564
  *
1565
+ * @param zc The compression context to be used for ZSTD_compress2(). Set any
1566
+ * compression parameters you need on this context.
1567
+ * @param outSeqs The output sequences buffer of size @p outSeqsSize
1568
+ * @param outSeqsSize The size of the output sequences buffer.
1569
+ * ZSTD_sequenceBound(srcSize) is an upper bound on the number
1570
+ * of sequences that can be generated.
1571
+ * @param src The source buffer to generate sequences from of size @p srcSize.
1572
+ * @param srcSize The size of the source buffer.
1573
+ *
1532
1574
  * Each block will end with a dummy sequence
1533
1575
  * with offset == 0, matchLength == 0, and litLength == length of last literals.
1534
1576
  * litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
1535
1577
  * simply acts as a block delimiter.
1536
1578
  *
1537
- * @zc can be used to insert custom compression params.
1538
- * This function invokes ZSTD_compress2().
1539
- *
1540
- * The output of this function can be fed into ZSTD_compressSequences() with CCtx
1541
- * setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
1542
- * @return : number of sequences generated
1579
+ * @returns The number of sequences generated, necessarily less than
1580
+ * ZSTD_sequenceBound(srcSize), or an error code that can be checked
1581
+ * with ZSTD_isError().
1543
1582
  */
1544
-
1583
+ ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()")
1545
1584
  ZSTDLIB_STATIC_API size_t
1546
- ZSTD_generateSequences( ZSTD_CCtx* zc,
1547
- ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1548
- const void* src, size_t srcSize);
1585
+ ZSTD_generateSequences(ZSTD_CCtx* zc,
1586
+ ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1587
+ const void* src, size_t srcSize);
1549
1588
 
1550
1589
  /*! ZSTD_mergeBlockDelimiters() :
1551
1590
  * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
@@ -1640,56 +1679,59 @@ ZSTDLIB_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1640
1679
  /*! ZSTD_estimate*() :
1641
1680
  * These functions make it possible to estimate memory usage
1642
1681
  * of a future {D,C}Ctx, before its creation.
1682
+ * This is useful in combination with ZSTD_initStatic(),
1683
+ * which makes it possible to employ a static buffer for ZSTD_CCtx* state.
1643
1684
  *
1644
1685
  * ZSTD_estimateCCtxSize() will provide a memory budget large enough
1645
- * for any compression level up to selected one.
1646
- * Note : Unlike ZSTD_estimateCStreamSize*(), this estimate
1647
- * does not include space for a window buffer.
1648
- * Therefore, the estimation is only guaranteed for single-shot compressions, not streaming.
1686
+ * to compress data of any size using one-shot compression ZSTD_compressCCtx() or ZSTD_compress2()
1687
+ * associated with any compression level up to max specified one.
1649
1688
  * The estimate will assume the input may be arbitrarily large,
1650
1689
  * which is the worst case.
1651
1690
  *
1691
+ * Note that the size estimation is specific for one-shot compression,
1692
+ * it is not valid for streaming (see ZSTD_estimateCStreamSize*())
1693
+ * nor other potential ways of using a ZSTD_CCtx* state.
1694
+ *
1652
1695
  * When srcSize can be bound by a known and rather "small" value,
1653
- * this fact can be used to provide a tighter estimation
1654
- * because the CCtx compression context will need less memory.
1655
- * This tighter estimation can be provided by more advanced functions
1696
+ * this knowledge can be used to provide a tighter budget estimation
1697
+ * because the ZSTD_CCtx* state will need less memory for small inputs.
1698
+ * This tighter estimation can be provided by employing more advanced functions
1656
1699
  * ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(),
1657
1700
  * and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter().
1658
1701
  * Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits.
1659
1702
  *
1660
1703
  * Note : only single-threaded compression is supported.
1661
1704
  * ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.
1662
- *
1663
- * Note 2 : ZSTD_estimateCCtxSize* functions are not compatible with the Block-Level Sequence Producer API at this time.
1664
- * Size estimates assume that no external sequence producer is registered.
1665
1705
  */
1666
- ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
1706
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int maxCompressionLevel);
1667
1707
  ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
1668
1708
  ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1669
1709
  ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void);
1670
1710
 
1671
1711
  /*! ZSTD_estimateCStreamSize() :
1672
- * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
1673
- * It will also consider src size to be arbitrarily "large", which is worst case.
1712
+ * ZSTD_estimateCStreamSize() will provide a memory budget large enough for streaming compression
1713
+ * using any compression level up to the max specified one.
1714
+ * It will also consider src size to be arbitrarily "large", which is a worst case scenario.
1674
1715
  * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation.
1675
1716
  * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
1676
1717
  * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParams_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1.
1677
1718
  * Note : CStream size estimation is only correct for single-threaded compression.
1678
- * ZSTD_DStream memory budget depends on window Size.
1719
+ * ZSTD_estimateCStreamSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.
1720
+ * Note 2 : ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time.
1721
+ * Size estimates assume that no external sequence producer is registered.
1722
+ *
1723
+ * ZSTD_DStream memory budget depends on frame's window Size.
1679
1724
  * This information can be passed manually, using ZSTD_estimateDStreamSize,
1680
1725
  * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame();
1726
+ * Any frame requesting a window size larger than max specified one will be rejected.
1681
1727
  * Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
1682
1728
  * an internal ?Dict will be created, which additional size is not estimated here.
1683
1729
  * In this case, get total size by adding ZSTD_estimate?DictSize
1684
- * Note 2 : only single-threaded compression is supported.
1685
- * ZSTD_estimateCStreamSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.
1686
- * Note 3 : ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time.
1687
- * Size estimates assume that no external sequence producer is registered.
1688
1730
  */
1689
- ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
1731
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int maxCompressionLevel);
1690
1732
  ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
1691
1733
  ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1692
- ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
1734
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t maxWindowSize);
1693
1735
  ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
1694
1736
 
1695
1737
  /*! ZSTD_estimate?DictSize() :
@@ -1946,11 +1988,6 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
1946
1988
  */
1947
1989
  #define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
1948
1990
 
1949
- /* Tries to fit compressed block size to be around targetCBlockSize.
1950
- * No target when targetCBlockSize == 0.
1951
- * There is no guarantee on compressed block size (default:0) */
1952
- #define ZSTD_c_targetCBlockSize ZSTD_c_experimentalParam6
1953
-
1954
1991
  /* User's best guess of source size.
1955
1992
  * Hint is not valid when srcSizeHint == 0.
1956
1993
  * There is no guarantee that hint is close to actual source size,
@@ -2430,6 +2467,22 @@ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParamete
2430
2467
  */
2431
2468
  #define ZSTD_d_disableHuffmanAssembly ZSTD_d_experimentalParam5
2432
2469
 
2470
+ /* ZSTD_d_maxBlockSize
2471
+ * Allowed values are between 1KB and ZSTD_BLOCKSIZE_MAX (128KB).
2472
+ * The default is ZSTD_BLOCKSIZE_MAX, and setting to 0 will set to the default.
2473
+ *
2474
+ * Forces the decompressor to reject blocks whose content size is
2475
+ * larger than the configured maxBlockSize. When maxBlockSize is
2476
+ * larger than the windowSize, the windowSize is used instead.
2477
+ * This saves memory on the decoder when you know all blocks are small.
2478
+ *
2479
+ * This option is typically used in conjunction with ZSTD_c_maxBlockSize.
2480
+ *
2481
+ * WARNING: This causes the decoder to reject otherwise valid frames
2482
+ * that have block sizes larger than the configured maxBlockSize.
2483
+ */
2484
+ #define ZSTD_d_maxBlockSize ZSTD_d_experimentalParam6
2485
+
2433
2486
 
2434
2487
  /*! ZSTD_DCtx_setFormat() :
2435
2488
  * This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter().
@@ -2557,7 +2610,7 @@ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
2557
2610
  * explicitly specified.
2558
2611
  *
2559
2612
  * start a new frame, using same parameters from previous frame.
2560
- * This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
2613
+ * This is typically useful to skip dictionary loading stage, since it will reuse it in-place.
2561
2614
  * Note that zcs must be init at least once before using ZSTD_resetCStream().
2562
2615
  * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN.
2563
2616
  * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
@@ -2633,7 +2686,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const Z
2633
2686
  *
2634
2687
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
2635
2688
  *
2636
- * re-use decompression parameters from previous init; saves dictionary loading
2689
+ * reuse decompression parameters from previous init; saves dictionary loading
2637
2690
  */
2638
2691
  ZSTD_DEPRECATED("use ZSTD_DCtx_reset, see zstd.h for detailed instructions")
2639
2692
  ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
@@ -2765,7 +2818,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
2765
2818
 
2766
2819
  #define ZSTD_SEQUENCE_PRODUCER_ERROR ((size_t)(-1))
2767
2820
 
2768
- typedef size_t ZSTD_sequenceProducer_F (
2821
+ typedef size_t (*ZSTD_sequenceProducer_F) (
2769
2822
  void* sequenceProducerState,
2770
2823
  ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
2771
2824
  const void* src, size_t srcSize,
@@ -2797,7 +2850,23 @@ ZSTDLIB_STATIC_API void
2797
2850
  ZSTD_registerSequenceProducer(
2798
2851
  ZSTD_CCtx* cctx,
2799
2852
  void* sequenceProducerState,
2800
- ZSTD_sequenceProducer_F* sequenceProducer
2853
+ ZSTD_sequenceProducer_F sequenceProducer
2854
+ );
2855
+
2856
+ /*! ZSTD_CCtxParams_registerSequenceProducer() :
2857
+ * Same as ZSTD_registerSequenceProducer(), but operates on ZSTD_CCtx_params.
2858
+ * This is used for accurate size estimation with ZSTD_estimateCCtxSize_usingCCtxParams(),
2859
+ * which is needed when creating a ZSTD_CCtx with ZSTD_initStaticCCtx().
2860
+ *
2861
+ * If you are using the external sequence producer API in a scenario where ZSTD_initStaticCCtx()
2862
+ * is required, then this function is for you. Otherwise, you probably don't need it.
2863
+ *
2864
+ * See tests/zstreamtest.c for example usage. */
2865
+ ZSTDLIB_STATIC_API void
2866
+ ZSTD_CCtxParams_registerSequenceProducer(
2867
+ ZSTD_CCtx_params* params,
2868
+ void* sequenceProducerState,
2869
+ ZSTD_sequenceProducer_F sequenceProducer
2801
2870
  );
2802
2871
 
2803
2872
 
@@ -2820,7 +2889,7 @@ ZSTD_registerSequenceProducer(
2820
2889
 
2821
2890
  A ZSTD_CCtx object is required to track streaming operations.
2822
2891
  Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
2823
- ZSTD_CCtx object can be re-used multiple times within successive compression operations.
2892
+ ZSTD_CCtx object can be reused multiple times within successive compression operations.
2824
2893
 
2825
2894
  Start by initializing a context.
2826
2895
  Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
@@ -2841,7 +2910,7 @@ ZSTD_registerSequenceProducer(
2841
2910
  It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
2842
2911
  Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
2843
2912
 
2844
- `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
2913
+ `ZSTD_CCtx` object can be reused (ZSTD_compressBegin()) to compress again.
2845
2914
  */
2846
2915
 
2847
2916
  /*===== Buffer-less streaming compression functions =====*/
@@ -2873,7 +2942,7 @@ size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_
2873
2942
 
2874
2943
  A ZSTD_DCtx object is required to track streaming operations.
2875
2944
  Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
2876
- A ZSTD_DCtx object can be re-used multiple times.
2945
+ A ZSTD_DCtx object can be reused multiple times.
2877
2946
 
2878
2947
  First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
2879
2948
  Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
@@ -11,9 +11,7 @@
11
11
  /* gzclose() is in a separate file so that it is linked in only if it is used.
12
12
  That way the other gzclose functions can be used instead to avoid linking in
13
13
  unneeded compression or decompression routines. */
14
- int ZEXPORT gzclose(file)
15
- gzFile file;
16
- {
14
+ int ZEXPORT gzclose(gzFile file) {
17
15
  #ifndef NO_GZCOMPRESS
18
16
  gz_statep state;
19
17