zstdlib 0.6.0-x64-mingw32 → 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +20 -0
  3. data/README.md +7 -1
  4. data/Rakefile +38 -8
  5. data/ext/{zstdlib → zstdlib_c}/extconf.rb +10 -5
  6. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
  7. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
  8. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
  9. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
  10. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
  11. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
  12. data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
  13. data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
  14. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/adler32.c +0 -0
  15. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/compress.c +0 -0
  16. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.c +0 -0
  17. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.h +0 -0
  18. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.c +0 -0
  19. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.h +0 -0
  20. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzclose.c +0 -0
  21. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzguts.h +0 -0
  22. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzlib.c +0 -0
  23. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzread.c +0 -0
  24. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzwrite.c +0 -0
  25. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/infback.c +0 -0
  26. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.c +0 -0
  27. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.h +0 -0
  28. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffixed.h +0 -0
  29. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.c +0 -0
  30. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.h +0 -0
  31. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.c +0 -0
  32. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.h +0 -0
  33. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.c +0 -0
  34. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.h +0 -0
  35. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/uncompr.c +0 -0
  36. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zconf.h +0 -0
  37. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zlib.h +0 -0
  38. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.c +0 -0
  39. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.h +0 -0
  40. data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
  41. data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
  42. data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
  43. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +75 -57
  44. data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
  45. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +1 -3
  46. data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.c +24 -0
  47. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +22 -49
  48. data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
  49. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +3 -1
  50. data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
  51. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +51 -42
  52. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +149 -57
  53. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +60 -54
  54. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +87 -98
  55. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +34 -23
  56. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +5 -5
  57. data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
  58. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +10 -8
  59. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +4 -3
  60. data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
  61. data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
  62. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +10 -10
  63. data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
  64. data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_internal.h +493 -0
  65. data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
  66. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
  67. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +105 -85
  68. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +41 -63
  69. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +13 -33
  70. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
  71. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress.c +6327 -0
  72. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +537 -82
  73. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +21 -16
  74. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +4 -2
  75. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +61 -34
  76. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +10 -3
  77. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.c +573 -0
  78. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.h +32 -0
  79. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +236 -95
  80. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +321 -143
  81. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +2 -2
  82. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +328 -137
  83. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +2 -2
  84. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
  85. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
  86. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +336 -209
  87. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +15 -3
  88. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
  89. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +439 -239
  90. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +1 -1
  91. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +205 -462
  92. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
  93. data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress.c +1889 -0
  94. data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
  95. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +20 -16
  96. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +3 -3
  97. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +691 -230
  98. data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.c +2072 -0
  99. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +16 -7
  100. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +71 -10
  101. data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
  102. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +760 -234
  103. data/ext/{zstdlib/zstd-1.4.4/lib/common → zstdlib_c/zstd-1.5.2/lib}/zstd_errors.h +3 -1
  104. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
  105. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +1 -1
  106. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
  107. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
  108. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
  109. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
  110. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +133 -44
  111. data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +1 -1
  112. data/ext/zstdlib_c/zstd.mk +15 -0
  113. data/lib/2.4/zstdlib_c.so +0 -0
  114. data/lib/2.5/zstdlib_c.so +0 -0
  115. data/lib/2.6/zstdlib_c.so +0 -0
  116. data/lib/2.7/zstdlib_c.so +0 -0
  117. data/lib/3.0/zstdlib_c.so +0 -0
  118. data/lib/zstdlib.rb +2 -2
  119. metadata +124 -114
  120. data/ext/zstdlib/zstd-1.4.4/lib/common/compiler.h +0 -159
  121. data/ext/zstdlib/zstd-1.4.4/lib/common/debug.c +0 -44
  122. data/ext/zstdlib/zstd-1.4.4/lib/common/entropy_common.c +0 -236
  123. data/ext/zstdlib/zstd-1.4.4/lib/common/error_private.h +0 -76
  124. data/ext/zstdlib/zstd-1.4.4/lib/common/xxhash.c +0 -882
  125. data/ext/zstdlib/zstd-1.4.4/lib/common/xxhash.h +0 -305
  126. data/ext/zstdlib/zstd-1.4.4/lib/common/zstd_internal.h +0 -350
  127. data/ext/zstdlib/zstd-1.4.4/lib/compress/huf_compress.c +0 -798
  128. data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_compress.c +0 -4103
  129. data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_lazy.c +0 -1115
  130. data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_lazy.h +0 -67
  131. data/ext/zstdlib/zstd-1.4.4/lib/compress/zstdmt_compress.h +0 -192
  132. data/ext/zstdlib/zstd-1.4.4/lib/decompress/huf_decompress.c +0 -1234
  133. data/ext/zstdlib/zstd-1.4.4/lib/decompress/zstd_decompress_block.c +0 -1323
  134. data/ext/zstdlib/zstd.mk +0 -14
  135. data/lib/2.2/zstdlib.so +0 -0
  136. data/lib/2.3/zstdlib.so +0 -0
  137. data/lib/2.4/zstdlib.so +0 -0
  138. data/lib/2.5/zstdlib.so +0 -0
  139. data/lib/2.6/zstdlib.so +0 -0
  140. data/lib/2.7/zstdlib.so +0 -0
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, 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
@@ -20,19 +20,21 @@ extern "C" {
20
20
 
21
21
 
22
22
  /* ===== ZSTDLIB_API : control library symbols visibility ===== */
23
- #ifndef ZSTDLIB_VISIBILITY
24
- # if defined(__GNUC__) && (__GNUC__ >= 4)
25
- # define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
23
+ #ifndef ZSTDLIB_VISIBLE
24
+ # if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
25
+ # define ZSTDLIB_VISIBLE __attribute__ ((visibility ("default")))
26
+ # define ZSTDLIB_HIDDEN __attribute__ ((visibility ("hidden")))
26
27
  # else
27
- # define ZSTDLIB_VISIBILITY
28
+ # define ZSTDLIB_VISIBLE
29
+ # define ZSTDLIB_HIDDEN
28
30
  # endif
29
31
  #endif
30
32
  #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
31
- # define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
33
+ # define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBLE
32
34
  #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
33
- # define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
35
+ # define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
34
36
  #else
35
- # define ZSTDLIB_API ZSTDLIB_VISIBILITY
37
+ # define ZSTDLIB_API ZSTDLIB_VISIBLE
36
38
  #endif
37
39
 
38
40
 
@@ -71,17 +73,22 @@ extern "C" {
71
73
 
72
74
  /*------ Version ------*/
73
75
  #define ZSTD_VERSION_MAJOR 1
74
- #define ZSTD_VERSION_MINOR 4
75
- #define ZSTD_VERSION_RELEASE 4
76
-
76
+ #define ZSTD_VERSION_MINOR 5
77
+ #define ZSTD_VERSION_RELEASE 2
77
78
  #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 */
79
+
80
+ /*! ZSTD_versionNumber() :
81
+ * Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */
82
+ ZSTDLIB_API unsigned ZSTD_versionNumber(void);
79
83
 
80
84
  #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
81
85
  #define ZSTD_QUOTE(str) #str
82
86
  #define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
83
87
  #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
84
- ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
88
+
89
+ /*! ZSTD_versionString() :
90
+ * Return runtime library version, like "1.4.5". Requires v1.3.0+. */
91
+ ZSTDLIB_API const char* ZSTD_versionString(void);
85
92
 
86
93
  /* *************************************
87
94
  * Default constant
@@ -104,7 +111,6 @@ ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
104
111
  #define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
105
112
 
106
113
 
107
-
108
114
  /***************************************
109
115
  * Simple API
110
116
  ***************************************/
@@ -161,7 +167,7 @@ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t
161
167
  * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
162
168
  ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
163
169
 
164
- /*! ZSTD_findFrameCompressedSize() :
170
+ /*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+
165
171
  * `src` should point to the start of a ZSTD frame or skippable frame.
166
172
  * `srcSize` must be >= first frame size
167
173
  * @return : the compressed size of the first frame starting at `src`,
@@ -175,8 +181,9 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
175
181
  ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
176
182
  ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
177
183
  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 */
184
+ ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
179
185
  ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
186
+ ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
180
187
 
181
188
 
182
189
  /***************************************
@@ -194,7 +201,7 @@ ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compres
194
201
  */
195
202
  typedef struct ZSTD_CCtx_s ZSTD_CCtx;
196
203
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
197
- ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
204
+ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
198
205
 
199
206
  /*! ZSTD_compressCCtx() :
200
207
  * Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
@@ -217,7 +224,7 @@ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
217
224
  * Use one context per thread for parallel execution. */
218
225
  typedef struct ZSTD_DCtx_s ZSTD_DCtx;
219
226
  ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
220
- ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
227
+ ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */
221
228
 
222
229
  /*! ZSTD_decompressDCtx() :
223
230
  * Same as ZSTD_decompress(),
@@ -229,9 +236,9 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
229
236
  const void* src, size_t srcSize);
230
237
 
231
238
 
232
- /***************************************
233
- * Advanced compression API
234
- ***************************************/
239
+ /*********************************************
240
+ * Advanced compression API (Requires v1.4.0+)
241
+ **********************************************/
235
242
 
236
243
  /* API design :
237
244
  * Parameters are pushed one by one into an existing context,
@@ -242,7 +249,7 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
242
249
  *
243
250
  * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
244
251
  *
245
- * This API supercedes all other "advanced" API entry points in the experimental section.
252
+ * This API supersedes all other "advanced" API entry points in the experimental section.
246
253
  * In the future, we expect to remove from experimental API entry points which are redundant with this API.
247
254
  */
248
255
 
@@ -261,7 +268,6 @@ typedef enum { ZSTD_fast=1,
261
268
  Only the order (from fast to strong) is guaranteed */
262
269
  } ZSTD_strategy;
263
270
 
264
-
265
271
  typedef enum {
266
272
 
267
273
  /* compression parameters
@@ -274,7 +280,10 @@ typedef enum {
274
280
  * Default level is ZSTD_CLEVEL_DEFAULT==3.
275
281
  * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
276
282
  * Note 1 : it's possible to pass a negative compression level.
277
- * Note 2 : setting a level resets all other compression parameters to default */
283
+ * Note 2 : setting a level does not automatically set all other compression parameters
284
+ * to default. Setting this will however eventually dynamically impact the compression
285
+ * parameters which have not been manually set. The manually set
286
+ * ones will 'stick'. */
278
287
  /* Advanced compression parameters :
279
288
  * It's possible to pin down compression parameters to some specific values.
280
289
  * In which case, these values are no longer dynamically selected by the compressor */
@@ -324,14 +333,15 @@ typedef enum {
324
333
  * The higher the value of selected strategy, the more complex it is,
325
334
  * resulting in stronger and slower compression.
326
335
  * Special: value 0 means "use default strategy". */
327
-
328
336
  /* LDM mode parameters */
329
337
  ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
330
338
  * This parameter is designed to improve compression ratio
331
339
  * for large inputs, by finding large matches at long distance.
332
340
  * It increases memory usage and window size.
333
341
  * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
334
- * except when expressly set to a different value. */
342
+ * except when expressly set to a different value.
343
+ * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
344
+ * compression strategy >= ZSTD_btopt (== compression level 16+) */
335
345
  ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
336
346
  * Larger values increase memory usage and compression ratio,
337
347
  * but decrease compression speed.
@@ -362,20 +372,24 @@ typedef enum {
362
372
  ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
363
373
 
364
374
  /* multi-threading parameters */
365
- /* These parameters are only useful if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
366
- * They return an error otherwise. */
375
+ /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
376
+ * Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
377
+ * In a situation where it's unknown if the linked library supports multi-threading or not,
378
+ * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
379
+ */
367
380
  ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
368
- * When nbWorkers >= 1, triggers asynchronous mode when used with ZSTD_compressStream*() :
381
+ * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
369
382
  * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
370
- * while compression work is performed in parallel, within worker threads.
383
+ * while compression is performed in parallel, within worker thread(s).
371
384
  * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
372
385
  * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
373
386
  * More workers improve speed, but also increase memory usage.
374
- * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */
387
+ * Default value is `0`, aka "single-threaded mode" : no worker is spawned,
388
+ * compression is performed inside Caller's thread, and all invocations are blocking */
375
389
  ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
376
390
  * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
377
391
  * 0 means default, which is dynamically determined based on compression parameters.
378
- * Job size must be a minimum of overlap size, or 1 MB, whichever is largest.
392
+ * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
379
393
  * The minimum size is automatically and transparently enforced. */
380
394
  ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
381
395
  * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
@@ -400,6 +414,13 @@ typedef enum {
400
414
  * ZSTD_c_literalCompressionMode
401
415
  * ZSTD_c_targetCBlockSize
402
416
  * ZSTD_c_srcSizeHint
417
+ * ZSTD_c_enableDedicatedDictSearch
418
+ * ZSTD_c_stableInBuffer
419
+ * ZSTD_c_stableOutBuffer
420
+ * ZSTD_c_blockDelimiters
421
+ * ZSTD_c_validateSequences
422
+ * ZSTD_c_useBlockSplitter
423
+ * ZSTD_c_useRowMatchFinder
403
424
  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
404
425
  * note : never ever use experimentalParam? names directly;
405
426
  * also, the enums values themselves are unstable and can still change.
@@ -410,7 +431,15 @@ typedef enum {
410
431
  ZSTD_c_experimentalParam4=1001,
411
432
  ZSTD_c_experimentalParam5=1002,
412
433
  ZSTD_c_experimentalParam6=1003,
413
- ZSTD_c_experimentalParam7=1004
434
+ ZSTD_c_experimentalParam7=1004,
435
+ ZSTD_c_experimentalParam8=1005,
436
+ ZSTD_c_experimentalParam9=1006,
437
+ ZSTD_c_experimentalParam10=1007,
438
+ ZSTD_c_experimentalParam11=1008,
439
+ ZSTD_c_experimentalParam12=1009,
440
+ ZSTD_c_experimentalParam13=1010,
441
+ ZSTD_c_experimentalParam14=1011,
442
+ ZSTD_c_experimentalParam15=1012
414
443
  } ZSTD_cParameter;
415
444
 
416
445
  typedef struct {
@@ -495,9 +524,9 @@ ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
495
524
  const void* src, size_t srcSize);
496
525
 
497
526
 
498
- /***************************************
499
- * Advanced decompression API
500
- ***************************************/
527
+ /***********************************************
528
+ * Advanced decompression API (Requires v1.4.0+)
529
+ ************************************************/
501
530
 
502
531
  /* The advanced API pushes parameters one by one into an existing DCtx context.
503
532
  * Parameters are sticky, and remain valid for all following frames
@@ -519,11 +548,17 @@ typedef enum {
519
548
  /* note : additional experimental parameters are also available
520
549
  * within the experimental section of the API.
521
550
  * At the time of this writing, they include :
522
- * ZSTD_c_format
551
+ * ZSTD_d_format
552
+ * ZSTD_d_stableOutBuffer
553
+ * ZSTD_d_forceIgnoreChecksum
554
+ * ZSTD_d_refMultipleDDicts
523
555
  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
524
556
  * note : never ever use experimentalParam? names directly
525
557
  */
526
- ZSTD_d_experimentalParam1=1000
558
+ ZSTD_d_experimentalParam1=1000,
559
+ ZSTD_d_experimentalParam2=1001,
560
+ ZSTD_d_experimentalParam3=1002,
561
+ ZSTD_d_experimentalParam4=1003
527
562
 
528
563
  } ZSTD_dParameter;
529
564
 
@@ -637,7 +672,7 @@ typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same
637
672
  /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
638
673
  /*===== ZSTD_CStream management functions =====*/
639
674
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
640
- ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
675
+ ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */
641
676
 
642
677
  /*===== Streaming compression functions =====*/
643
678
  typedef enum {
@@ -653,14 +688,15 @@ typedef enum {
653
688
  : note : multithreaded compression will block to flush as much output as possible. */
654
689
  } ZSTD_EndDirective;
655
690
 
656
- /*! ZSTD_compressStream2() :
691
+ /*! ZSTD_compressStream2() : Requires v1.4.0+
657
692
  * Behaves about the same as ZSTD_compressStream, with additional control on end directive.
658
693
  * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
659
694
  * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
660
695
  * - output->pos must be <= dstCapacity, input->pos must be <= srcSize
661
696
  * - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
697
+ * - endOp must be a valid directive
662
698
  * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
663
- * - 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,
699
+ * - 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,
664
700
  * and then immediately returns, just indicating that there is some data remaining to be flushed.
665
701
  * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
666
702
  * - 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.
@@ -698,11 +734,11 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
698
734
 
699
735
 
700
736
  /* *****************************************************************************
701
- * This following is a legacy streaming API.
737
+ * This following is a legacy streaming API, available since v1.0+ .
702
738
  * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
703
739
  * It is redundant, but remains fully supported.
704
- * Advanced parameters and dictionary compression can only be used through the
705
- * new API.
740
+ * Streaming in combination with advanced parameters and dictionary compression
741
+ * can only be used through the new API.
706
742
  ******************************************************************************/
707
743
 
708
744
  /*!
@@ -757,13 +793,13 @@ typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same
757
793
  /* For compatibility with versions <= v1.2.0, prefer differentiating them. */
758
794
  /*===== ZSTD_DStream management functions =====*/
759
795
  ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
760
- ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
796
+ ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */
761
797
 
762
798
  /*===== Streaming decompression functions =====*/
763
799
 
764
800
  /* This function is redundant with the advanced API and equivalent to:
765
801
  *
766
- * ZSTD_DCtx_reset(zds);
802
+ * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
767
803
  * ZSTD_DCtx_refDDict(zds, NULL);
768
804
  */
769
805
  ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
@@ -780,7 +816,7 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
780
816
  /*! ZSTD_compress_usingDict() :
781
817
  * Compression at an explicit compression level using a Dictionary.
782
818
  * A dictionary can be any arbitrary data segment (also called a prefix),
783
- * or a buffer with specified information (see dictBuilder/zdict.h).
819
+ * or a buffer with specified information (see zdict.h).
784
820
  * Note : This function loads the dictionary, resulting in significant startup delay.
785
821
  * It's intended for a dictionary used only once.
786
822
  * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */
@@ -823,7 +859,8 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize
823
859
  int compressionLevel);
824
860
 
825
861
  /*! ZSTD_freeCDict() :
826
- * Function frees memory allocated by ZSTD_createCDict(). */
862
+ * Function frees memory allocated by ZSTD_createCDict().
863
+ * If a NULL pointer is passed, no operation is performed. */
827
864
  ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
828
865
 
829
866
  /*! ZSTD_compress_usingCDict() :
@@ -845,7 +882,8 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
845
882
  ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
846
883
 
847
884
  /*! ZSTD_freeDDict() :
848
- * Function frees memory allocated with ZSTD_createDDict() */
885
+ * Function frees memory allocated with ZSTD_createDDict()
886
+ * If a NULL pointer is passed, no operation is performed. */
849
887
  ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
850
888
 
851
889
  /*! ZSTD_decompress_usingDDict() :
@@ -861,19 +899,25 @@ ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
861
899
  * Dictionary helper functions
862
900
  *******************************/
863
901
 
864
- /*! ZSTD_getDictID_fromDict() :
902
+ /*! ZSTD_getDictID_fromDict() : Requires v1.4.0+
865
903
  * Provides the dictID stored within dictionary.
866
904
  * if @return == 0, the dictionary is not conformant with Zstandard specification.
867
905
  * It can still be loaded, but as a content-only dictionary. */
868
906
  ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
869
907
 
870
- /*! ZSTD_getDictID_fromDDict() :
908
+ /*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+
909
+ * Provides the dictID of the dictionary loaded into `cdict`.
910
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
911
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
912
+ ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
913
+
914
+ /*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+
871
915
  * Provides the dictID of the dictionary loaded into `ddict`.
872
916
  * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
873
917
  * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
874
918
  ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
875
919
 
876
- /*! ZSTD_getDictID_fromFrame() :
920
+ /*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+
877
921
  * Provides the dictID required to decompressed the frame stored within `src`.
878
922
  * If @return == 0, the dictID could not be decoded.
879
923
  * This could for one of the following reasons :
@@ -887,16 +931,16 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
887
931
 
888
932
 
889
933
  /*******************************************************************************
890
- * Advanced dictionary and prefix API
934
+ * Advanced dictionary and prefix API (Requires v1.4.0+)
891
935
  *
892
936
  * This API allows dictionaries to be used with ZSTD_compress2(),
893
- * ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and
937
+ * ZSTD_compressStream2(), and ZSTD_decompressDCtx(). Dictionaries are sticky, and
894
938
  * only reset with the context is reset with ZSTD_reset_parameters or
895
939
  * ZSTD_reset_session_and_parameters. Prefixes are single-use.
896
940
  ******************************************************************************/
897
941
 
898
942
 
899
- /*! ZSTD_CCtx_loadDictionary() :
943
+ /*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+
900
944
  * Create an internal CDict from `dict` buffer.
901
945
  * Decompression will have to use same dictionary.
902
946
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
@@ -915,11 +959,11 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
915
959
  * to precisely select how dictionary content must be interpreted. */
916
960
  ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
917
961
 
918
- /*! ZSTD_CCtx_refCDict() :
962
+ /*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
919
963
  * Reference a prepared dictionary, to be used for all next compressed frames.
920
964
  * Note that compression parameters are enforced from within CDict,
921
965
  * and supersede any compression parameter previously set within CCtx.
922
- * The parameters ignored are labled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
966
+ * The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
923
967
  * The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.
924
968
  * The dictionary will remain valid for future compressed frames using same CCtx.
925
969
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
@@ -929,7 +973,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
929
973
  * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */
930
974
  ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
931
975
 
932
- /*! ZSTD_CCtx_refPrefix() :
976
+ /*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+
933
977
  * Reference a prefix (single-usage dictionary) for next compressed frame.
934
978
  * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
935
979
  * Decompression will need same prefix to properly regenerate data.
@@ -950,7 +994,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
950
994
  ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
951
995
  const void* prefix, size_t prefixSize);
952
996
 
953
- /*! ZSTD_DCtx_loadDictionary() :
997
+ /*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
954
998
  * Create an internal DDict from dict buffer,
955
999
  * to be used to decompress next frames.
956
1000
  * The dictionary remains valid for all future frames, until explicitly invalidated.
@@ -967,9 +1011,16 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
967
1011
  */
968
1012
  ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
969
1013
 
970
- /*! ZSTD_DCtx_refDDict() :
1014
+ /*! ZSTD_DCtx_refDDict() : Requires v1.4.0+
971
1015
  * Reference a prepared dictionary, to be used to decompress next frames.
972
1016
  * The dictionary remains active for decompression of future frames using same DCtx.
1017
+ *
1018
+ * If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
1019
+ * will store the DDict references in a table, and the DDict used for decompression
1020
+ * will be determined at decompression time, as per the dict ID in the frame.
1021
+ * The memory for the table is allocated on the first call to refDDict, and can be
1022
+ * freed with ZSTD_freeDCtx().
1023
+ *
973
1024
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
974
1025
  * Note 1 : Currently, only one dictionary can be managed.
975
1026
  * Referencing a new dictionary effectively "discards" any previous one.
@@ -978,7 +1029,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
978
1029
  */
979
1030
  ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
980
1031
 
981
- /*! ZSTD_DCtx_refPrefix() :
1032
+ /*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+
982
1033
  * Reference a prefix (single-usage dictionary) to decompress next frame.
983
1034
  * This is the reverse operation of ZSTD_CCtx_refPrefix(),
984
1035
  * and must use the same prefix as the one used during compression.
@@ -999,7 +1050,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
999
1050
 
1000
1051
  /* === Memory management === */
1001
1052
 
1002
- /*! ZSTD_sizeof_*() :
1053
+ /*! ZSTD_sizeof_*() : Requires v1.4.0+
1003
1054
  * These functions give the _current_ memory usage of selected object.
1004
1055
  * Note that object memory usage can evolve (increase or decrease) over time. */
1005
1056
  ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
@@ -1024,6 +1075,39 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1024
1075
  #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
1025
1076
  #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
1026
1077
 
1078
+ /* This can be overridden externally to hide static symbols. */
1079
+ #ifndef ZSTDLIB_STATIC_API
1080
+ # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
1081
+ # define ZSTDLIB_STATIC_API __declspec(dllexport) ZSTDLIB_VISIBLE
1082
+ # elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
1083
+ # define ZSTDLIB_STATIC_API __declspec(dllimport) ZSTDLIB_VISIBLE
1084
+ # else
1085
+ # define ZSTDLIB_STATIC_API ZSTDLIB_VISIBLE
1086
+ # endif
1087
+ #endif
1088
+
1089
+ /* Deprecation warnings :
1090
+ * Should these warnings be a problem, it is generally possible to disable them,
1091
+ * typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual.
1092
+ * Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS.
1093
+ */
1094
+ #ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS
1095
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API /* disable deprecation warnings */
1096
+ #else
1097
+ # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
1098
+ # define ZSTD_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_STATIC_API
1099
+ # elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
1100
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated(message)))
1101
+ # elif defined(__GNUC__) && (__GNUC__ >= 3)
1102
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated))
1103
+ # elif defined(_MSC_VER)
1104
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __declspec(deprecated(message))
1105
+ # else
1106
+ # pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler")
1107
+ # define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API
1108
+ # endif
1109
+ #endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */
1110
+
1027
1111
  /****************************************************************************************
1028
1112
  * experimental API (static linking only)
1029
1113
  ****************************************************************************************
@@ -1086,30 +1170,46 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1086
1170
  #define ZSTD_SRCSIZEHINT_MIN 0
1087
1171
  #define ZSTD_SRCSIZEHINT_MAX INT_MAX
1088
1172
 
1089
- /* internal */
1090
- #define ZSTD_HASHLOG3_MAX 17
1091
-
1092
1173
 
1093
1174
  /* --- Advanced types --- */
1094
1175
 
1095
1176
  typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
1096
1177
 
1097
1178
  typedef struct {
1098
- unsigned int matchPos; /* Match pos in dst */
1099
- /* If seqDef.offset > 3, then this is seqDef.offset - 3
1100
- * If seqDef.offset < 3, then this is the corresponding repeat offset
1101
- * But if seqDef.offset < 3 and litLength == 0, this is the
1102
- * repeat offset before the corresponding repeat offset
1103
- * And if seqDef.offset == 3 and litLength == 0, this is the
1104
- * most recent repeat offset - 1
1105
- */
1106
- unsigned int offset;
1107
- unsigned int litLength; /* Literal length */
1108
- unsigned int matchLength; /* Match length */
1109
- /* 0 when seq not rep and seqDef.offset otherwise
1110
- * when litLength == 0 this will be <= 4, otherwise <= 3 like normal
1111
- */
1112
- unsigned int rep;
1179
+ unsigned int offset; /* The offset of the match. (NOT the same as the offset code)
1180
+ * If offset == 0 and matchLength == 0, this sequence represents the last
1181
+ * literals in the block of litLength size.
1182
+ */
1183
+
1184
+ unsigned int litLength; /* Literal length of the sequence. */
1185
+ unsigned int matchLength; /* Match length of the sequence. */
1186
+
1187
+ /* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
1188
+ * In this case, we will treat the sequence as a marker for a block boundary.
1189
+ */
1190
+
1191
+ unsigned int rep; /* Represents which repeat offset is represented by the field 'offset'.
1192
+ * Ranges from [0, 3].
1193
+ *
1194
+ * Repeat offsets are essentially previous offsets from previous sequences sorted in
1195
+ * recency order. For more detail, see doc/zstd_compression_format.md
1196
+ *
1197
+ * If rep == 0, then 'offset' does not contain a repeat offset.
1198
+ * If rep > 0:
1199
+ * If litLength != 0:
1200
+ * rep == 1 --> offset == repeat_offset_1
1201
+ * rep == 2 --> offset == repeat_offset_2
1202
+ * rep == 3 --> offset == repeat_offset_3
1203
+ * If litLength == 0:
1204
+ * rep == 1 --> offset == repeat_offset_2
1205
+ * rep == 2 --> offset == repeat_offset_3
1206
+ * rep == 3 --> offset == repeat_offset_1 - 1
1207
+ *
1208
+ * Note: This field is optional. ZSTD_generateSequences() will calculate the value of
1209
+ * 'rep', but repeat offsets do not necessarily need to be calculated from an external
1210
+ * sequence provider's perspective. For example, ZSTD_compressSequences() does not
1211
+ * use this 'rep' field at all (as of now).
1212
+ */
1113
1213
  } ZSTD_Sequence;
1114
1214
 
1115
1215
  typedef struct {
@@ -1151,6 +1251,18 @@ typedef enum {
1151
1251
  * Decoder cannot recognise automatically this format, requiring this instruction. */
1152
1252
  } ZSTD_format_e;
1153
1253
 
1254
+ typedef enum {
1255
+ /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
1256
+ ZSTD_d_validateChecksum = 0,
1257
+ ZSTD_d_ignoreChecksum = 1
1258
+ } ZSTD_forceIgnoreChecksum_e;
1259
+
1260
+ typedef enum {
1261
+ /* Note: this enum controls ZSTD_d_refMultipleDDicts */
1262
+ ZSTD_rmd_refSingleDDict = 0,
1263
+ ZSTD_rmd_refMultipleDDicts = 1
1264
+ } ZSTD_refMultipleDDicts_e;
1265
+
1154
1266
  typedef enum {
1155
1267
  /* Note: this enum and the behavior it controls are effectively internal
1156
1268
  * implementation details of the compressor. They are expected to continue
@@ -1199,6 +1311,15 @@ typedef enum {
1199
1311
  ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */
1200
1312
  } ZSTD_literalCompressionMode_e;
1201
1313
 
1314
+ typedef enum {
1315
+ /* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final
1316
+ * decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
1317
+ * or ZSTD_ps_disable allow for a force enable/disable the feature.
1318
+ */
1319
+ ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */
1320
+ ZSTD_ps_enable = 1, /* Force-enable the feature */
1321
+ ZSTD_ps_disable = 2 /* Do not use the feature */
1322
+ } ZSTD_paramSwitch_e;
1202
1323
 
1203
1324
  /***************************************
1204
1325
  * Frame size functions
@@ -1225,14 +1346,14 @@ typedef enum {
1225
1346
  * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
1226
1347
  * read each contained frame header. This is fast as most of the data is skipped,
1227
1348
  * however it does mean that all frame data must be present and valid. */
1228
- ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
1349
+ ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
1229
1350
 
1230
1351
  /*! ZSTD_decompressBound() :
1231
1352
  * `src` should point to the start of a series of ZSTD encoded and/or skippable frames
1232
1353
  * `srcSize` must be the _exact_ size of this series
1233
1354
  * (i.e. there should be a frame boundary at `src + srcSize`)
1234
1355
  * @return : - upper-bound for the decompressed size of all data in all successive frames
1235
- * - if an error occured: ZSTD_CONTENTSIZE_ERROR
1356
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
1236
1357
  *
1237
1358
  * note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame.
1238
1359
  * note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`.
@@ -1240,22 +1361,119 @@ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t
1240
1361
  * note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by:
1241
1362
  * upper-bound = # blocks * min(128 KB, Window_Size)
1242
1363
  */
1243
- ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
1364
+ ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
1244
1365
 
1245
1366
  /*! ZSTD_frameHeaderSize() :
1246
1367
  * srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX.
1247
1368
  * @return : size of the Frame Header,
1248
1369
  * or an error code (if srcSize is too small) */
1249
- ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1370
+ ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1371
+
1372
+ typedef enum {
1373
+ ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
1374
+ ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
1375
+ } ZSTD_sequenceFormat_e;
1250
1376
 
1251
- /*! ZSTD_getSequences() :
1252
- * Extract sequences from the sequence store
1377
+ /*! ZSTD_generateSequences() :
1378
+ * Generate sequences using ZSTD_compress2, given a source buffer.
1379
+ *
1380
+ * Each block will end with a dummy sequence
1381
+ * with offset == 0, matchLength == 0, and litLength == length of last literals.
1382
+ * litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
1383
+ * simply acts as a block delimiter.
1384
+ *
1253
1385
  * zc can be used to insert custom compression params.
1254
1386
  * This function invokes ZSTD_compress2
1255
- * @return : number of sequences extracted
1387
+ *
1388
+ * The output of this function can be fed into ZSTD_compressSequences() with CCtx
1389
+ * setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
1390
+ * @return : number of sequences generated
1391
+ */
1392
+
1393
+ ZSTDLIB_STATIC_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1394
+ size_t outSeqsSize, const void* src, size_t srcSize);
1395
+
1396
+ /*! ZSTD_mergeBlockDelimiters() :
1397
+ * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
1398
+ * by merging them into into the literals of the next sequence.
1399
+ *
1400
+ * As such, the final generated result has no explicit representation of block boundaries,
1401
+ * and the final last literals segment is not represented in the sequences.
1402
+ *
1403
+ * The output of this function can be fed into ZSTD_compressSequences() with CCtx
1404
+ * setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters
1405
+ * @return : number of sequences left after merging
1406
+ */
1407
+ ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
1408
+
1409
+ /*! ZSTD_compressSequences() :
1410
+ * Compress an array of ZSTD_Sequence, generated from the original source buffer, into dst.
1411
+ * If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
1412
+ * The entire source is compressed into a single frame.
1413
+ *
1414
+ * The compression behavior changes based on cctx params. In particular:
1415
+ * If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain
1416
+ * no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on
1417
+ * the block size derived from the cctx, and sequences may be split. This is the default setting.
1418
+ *
1419
+ * If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
1420
+ * block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
1421
+ *
1422
+ * If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
1423
+ * behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
1424
+ * specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
1425
+ *
1426
+ * In addition to the two adjustable experimental params, there are other important cctx params.
1427
+ * - 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.
1428
+ * - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression.
1429
+ * - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
1430
+ * is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
1431
+ *
1432
+ * Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
1433
+ * Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
1434
+ * and cannot emit an RLE block that disagrees with the repcode history
1435
+ * @return : final compressed size or a ZSTD error.
1436
+ */
1437
+ ZSTDLIB_STATIC_API size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
1438
+ const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
1439
+ const void* src, size_t srcSize);
1440
+
1441
+
1442
+ /*! ZSTD_writeSkippableFrame() :
1443
+ * Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
1444
+ *
1445
+ * Skippable frames begin with a a 4-byte magic number. There are 16 possible choices of magic number,
1446
+ * ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
1447
+ * As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
1448
+ * the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1449
+ *
1450
+ * Returns an error if destination buffer is not large enough, if the source size is not representable
1451
+ * with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
1452
+ *
1453
+ * @return : number of bytes written or a ZSTD error.
1454
+ */
1455
+ ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
1456
+ const void* src, size_t srcSize, unsigned magicVariant);
1457
+
1458
+ /*! ZSTD_readSkippableFrame() :
1459
+ * Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
1460
+ *
1461
+ * The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
1462
+ * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
1463
+ * in the magicVariant.
1464
+ *
1465
+ * Returns an error if destination buffer is not large enough, or if the frame is not skippable.
1466
+ *
1467
+ * @return : number of bytes written or a ZSTD error.
1468
+ */
1469
+ ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
1470
+ const void* src, size_t srcSize);
1471
+
1472
+ /*! ZSTD_isSkippableFrame() :
1473
+ * Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
1256
1474
  */
1257
- ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1258
- size_t outSeqsSize, const void* src, size_t srcSize);
1475
+ ZSTDLIB_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1476
+
1259
1477
 
1260
1478
 
1261
1479
  /***************************************
@@ -1263,27 +1481,32 @@ ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1263
1481
  ***************************************/
1264
1482
 
1265
1483
  /*! ZSTD_estimate*() :
1266
- * These functions make it possible to estimate memory usage of a future
1267
- * {D,C}Ctx, before its creation.
1268
- *
1269
- * ZSTD_estimateCCtxSize() will provide a budget large enough for any
1270
- * compression level up to selected one. Unlike ZSTD_estimateCStreamSize*(),
1271
- * this estimate does not include space for a window buffer, so this estimate
1272
- * is guaranteed to be enough for single-shot compressions, but not streaming
1273
- * compressions. It will however assume the input may be arbitrarily large,
1274
- * which is the worst case. If srcSize is known to always be small,
1275
- * ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation.
1276
- * ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with
1277
- * ZSTD_getCParams() to create cParams from compressionLevel.
1278
- * ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with
1279
- * ZSTD_CCtxParams_setParameter().
1280
- *
1281
- * Note: only single-threaded compression is supported. This function will
1282
- * return an error code if ZSTD_c_nbWorkers is >= 1. */
1283
- ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
1284
- ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
1285
- ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1286
- ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
1484
+ * These functions make it possible to estimate memory usage
1485
+ * of a future {D,C}Ctx, before its creation.
1486
+ *
1487
+ * ZSTD_estimateCCtxSize() will provide a memory budget large enough
1488
+ * for any compression level up to selected one.
1489
+ * Note : Unlike ZSTD_estimateCStreamSize*(), this estimate
1490
+ * does not include space for a window buffer.
1491
+ * Therefore, the estimation is only guaranteed for single-shot compressions, not streaming.
1492
+ * The estimate will assume the input may be arbitrarily large,
1493
+ * which is the worst case.
1494
+ *
1495
+ * When srcSize can be bound by a known and rather "small" value,
1496
+ * this fact can be used to provide a tighter estimation
1497
+ * because the CCtx compression context will need less memory.
1498
+ * This tighter estimation can be provided by more advanced functions
1499
+ * ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(),
1500
+ * and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter().
1501
+ * Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits.
1502
+ *
1503
+ * Note 2 : only single-threaded compression is supported.
1504
+ * ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.
1505
+ */
1506
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
1507
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
1508
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1509
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void);
1287
1510
 
1288
1511
  /*! ZSTD_estimateCStreamSize() :
1289
1512
  * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
@@ -1298,20 +1521,20 @@ ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
1298
1521
  * Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
1299
1522
  * an internal ?Dict will be created, which additional size is not estimated here.
1300
1523
  * In this case, get total size by adding ZSTD_estimate?DictSize */
1301
- ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
1302
- ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
1303
- ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1304
- ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
1305
- ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
1524
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
1525
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
1526
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1527
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
1528
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
1306
1529
 
1307
1530
  /*! ZSTD_estimate?DictSize() :
1308
1531
  * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
1309
1532
  * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced().
1310
1533
  * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller.
1311
1534
  */
1312
- ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
1313
- ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
1314
- ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
1535
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
1536
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
1537
+ ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
1315
1538
 
1316
1539
  /*! ZSTD_initStatic*() :
1317
1540
  * Initialize an object using a pre-allocated fixed-size buffer.
@@ -1334,20 +1557,20 @@ ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e
1334
1557
  * Limitation 2 : static cctx currently not compatible with multi-threading.
1335
1558
  * Limitation 3 : static dctx is incompatible with legacy support.
1336
1559
  */
1337
- ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
1338
- ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
1560
+ ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
1561
+ ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
1339
1562
 
1340
- ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
1341
- ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
1563
+ ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
1564
+ ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
1342
1565
 
1343
- ZSTDLIB_API const ZSTD_CDict* ZSTD_initStaticCDict(
1566
+ ZSTDLIB_STATIC_API const ZSTD_CDict* ZSTD_initStaticCDict(
1344
1567
  void* workspace, size_t workspaceSize,
1345
1568
  const void* dict, size_t dictSize,
1346
1569
  ZSTD_dictLoadMethod_e dictLoadMethod,
1347
1570
  ZSTD_dictContentType_e dictContentType,
1348
1571
  ZSTD_compressionParameters cParams);
1349
1572
 
1350
- ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
1573
+ ZSTDLIB_STATIC_API const ZSTD_DDict* ZSTD_initStaticDDict(
1351
1574
  void* workspace, size_t workspaceSize,
1352
1575
  const void* dict, size_t dictSize,
1353
1576
  ZSTD_dictLoadMethod_e dictLoadMethod,
@@ -1362,24 +1585,54 @@ ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
1362
1585
  typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
1363
1586
  typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
1364
1587
  typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
1365
- static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
1588
+ static
1589
+ #ifdef __GNUC__
1590
+ __attribute__((__unused__))
1591
+ #endif
1592
+ ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
1366
1593
 
1367
- ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1368
- ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
1369
- ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
1370
- ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
1594
+ ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1595
+ ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
1596
+ ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
1597
+ ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
1371
1598
 
1372
- ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
1599
+ ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
1373
1600
  ZSTD_dictLoadMethod_e dictLoadMethod,
1374
1601
  ZSTD_dictContentType_e dictContentType,
1375
1602
  ZSTD_compressionParameters cParams,
1376
1603
  ZSTD_customMem customMem);
1377
1604
 
1378
- ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
1379
- ZSTD_dictLoadMethod_e dictLoadMethod,
1380
- ZSTD_dictContentType_e dictContentType,
1381
- ZSTD_customMem customMem);
1605
+ /*! Thread pool :
1606
+ * These prototypes make it possible to share a thread pool among multiple compression contexts.
1607
+ * This can limit resources for applications with multiple threads where each one uses
1608
+ * a threaded compression mode (via ZSTD_c_nbWorkers parameter).
1609
+ * ZSTD_createThreadPool creates a new thread pool with a given number of threads.
1610
+ * Note that the lifetime of such pool must exist while being used.
1611
+ * ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
1612
+ * to use an internal thread pool).
1613
+ * ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer.
1614
+ */
1615
+ typedef struct POOL_ctx_s ZSTD_threadPool;
1616
+ ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
1617
+ ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */
1618
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
1619
+
1620
+
1621
+ /*
1622
+ * This API is temporary and is expected to change or disappear in the future!
1623
+ */
1624
+ ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced2(
1625
+ const void* dict, size_t dictSize,
1626
+ ZSTD_dictLoadMethod_e dictLoadMethod,
1627
+ ZSTD_dictContentType_e dictContentType,
1628
+ const ZSTD_CCtx_params* cctxParams,
1629
+ ZSTD_customMem customMem);
1382
1630
 
1631
+ ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_advanced(
1632
+ const void* dict, size_t dictSize,
1633
+ ZSTD_dictLoadMethod_e dictLoadMethod,
1634
+ ZSTD_dictContentType_e dictContentType,
1635
+ ZSTD_customMem customMem);
1383
1636
 
1384
1637
 
1385
1638
  /***************************************
@@ -1392,22 +1645,22 @@ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictS
1392
1645
  * As a consequence, `dictBuffer` **must** outlive CDict,
1393
1646
  * and its content must remain unmodified throughout the lifetime of CDict.
1394
1647
  * note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */
1395
- ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
1648
+ ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
1396
1649
 
1397
1650
  /*! ZSTD_getCParams() :
1398
1651
  * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
1399
1652
  * `estimatedSrcSize` value is optional, select 0 if not known */
1400
- ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1653
+ ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1401
1654
 
1402
1655
  /*! ZSTD_getParams() :
1403
1656
  * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
1404
1657
  * All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */
1405
- ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1658
+ ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1406
1659
 
1407
1660
  /*! ZSTD_checkCParams() :
1408
1661
  * Ensure param values remain within authorized range.
1409
1662
  * @return 0 on success, or an error code (can be checked with ZSTD_isError()) */
1410
- ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
1663
+ ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
1411
1664
 
1412
1665
  /*! ZSTD_adjustCParams() :
1413
1666
  * optimize params for a given `srcSize` and `dictSize`.
@@ -1415,23 +1668,25 @@ ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
1415
1668
  * `dictSize` must be `0` when there is no dictionary.
1416
1669
  * cPar can be invalid : all parameters will be clamped within valid range in the @return struct.
1417
1670
  * This function never fails (wide contract) */
1418
- ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
1671
+ ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
1419
1672
 
1420
1673
  /*! ZSTD_compress_advanced() :
1421
1674
  * Note : this function is now DEPRECATED.
1422
1675
  * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters.
1423
- * This prototype will be marked as deprecated and generate compilation warning on reaching v1.5.x */
1424
- ZSTDLIB_API size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
1676
+ * This prototype will generate compilation warnings. */
1677
+ ZSTD_DEPRECATED("use ZSTD_compress2")
1678
+ size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
1425
1679
  void* dst, size_t dstCapacity,
1426
1680
  const void* src, size_t srcSize,
1427
1681
  const void* dict,size_t dictSize,
1428
1682
  ZSTD_parameters params);
1429
1683
 
1430
1684
  /*! ZSTD_compress_usingCDict_advanced() :
1431
- * Note : this function is now REDUNDANT.
1685
+ * Note : this function is now DEPRECATED.
1432
1686
  * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters.
1433
- * This prototype will be marked as deprecated and generate compilation warning in some future version */
1434
- ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
1687
+ * This prototype will generate compilation warnings. */
1688
+ ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary")
1689
+ size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
1435
1690
  void* dst, size_t dstCapacity,
1436
1691
  const void* src, size_t srcSize,
1437
1692
  const ZSTD_CDict* cdict,
@@ -1441,18 +1696,18 @@ ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
1441
1696
  /*! ZSTD_CCtx_loadDictionary_byReference() :
1442
1697
  * Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx.
1443
1698
  * It saves some memory, but also requires that `dict` outlives its usage within `cctx` */
1444
- ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
1699
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
1445
1700
 
1446
1701
  /*! ZSTD_CCtx_loadDictionary_advanced() :
1447
1702
  * Same as ZSTD_CCtx_loadDictionary(), but gives finer control over
1448
1703
  * how to load the dictionary (by copy ? by reference ?)
1449
1704
  * and how to interpret it (automatic ? force raw mode ? full mode only ?) */
1450
- ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1705
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1451
1706
 
1452
1707
  /*! ZSTD_CCtx_refPrefix_advanced() :
1453
1708
  * Same as ZSTD_CCtx_refPrefix(), but gives finer control over
1454
1709
  * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
1455
- ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1710
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1456
1711
 
1457
1712
  /* === experimental parameters === */
1458
1713
  /* these parameters can be used with ZSTD_setParameter()
@@ -1491,9 +1746,15 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
1491
1746
  * See the comments on that enum for an explanation of the feature. */
1492
1747
  #define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
1493
1748
 
1494
- /* Controls how the literals are compressed (default is auto).
1495
- * The value must be of type ZSTD_literalCompressionMode_e.
1496
- * See ZSTD_literalCompressionMode_t enum definition for details.
1749
+ /* Controlled with ZSTD_paramSwitch_e enum.
1750
+ * Default is ZSTD_ps_auto.
1751
+ * Set to ZSTD_ps_disable to never compress literals.
1752
+ * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals
1753
+ * may still be emitted if huffman is not beneficial to use.)
1754
+ *
1755
+ * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1756
+ * literals compression based on the compression parameters - specifically,
1757
+ * negative compression levels do not use literal compression.
1497
1758
  */
1498
1759
  #define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
1499
1760
 
@@ -1508,12 +1769,192 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
1508
1769
  * but compression ratio may regress significantly if guess considerably underestimates */
1509
1770
  #define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
1510
1771
 
1772
+ /* Controls whether the new and experimental "dedicated dictionary search
1773
+ * structure" can be used. This feature is still rough around the edges, be
1774
+ * prepared for surprising behavior!
1775
+ *
1776
+ * How to use it:
1777
+ *
1778
+ * When using a CDict, whether to use this feature or not is controlled at
1779
+ * CDict creation, and it must be set in a CCtxParams set passed into that
1780
+ * construction (via ZSTD_createCDict_advanced2()). A compression will then
1781
+ * use the feature or not based on how the CDict was constructed; the value of
1782
+ * this param, set in the CCtx, will have no effect.
1783
+ *
1784
+ * However, when a dictionary buffer is passed into a CCtx, such as via
1785
+ * ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control
1786
+ * whether the CDict that is created internally can use the feature or not.
1787
+ *
1788
+ * What it does:
1789
+ *
1790
+ * Normally, the internal data structures of the CDict are analogous to what
1791
+ * would be stored in a CCtx after compressing the contents of a dictionary.
1792
+ * To an approximation, a compression using a dictionary can then use those
1793
+ * data structures to simply continue what is effectively a streaming
1794
+ * compression where the simulated compression of the dictionary left off.
1795
+ * Which is to say, the search structures in the CDict are normally the same
1796
+ * format as in the CCtx.
1797
+ *
1798
+ * It is possible to do better, since the CDict is not like a CCtx: the search
1799
+ * structures are written once during CDict creation, and then are only read
1800
+ * after that, while the search structures in the CCtx are both read and
1801
+ * written as the compression goes along. This means we can choose a search
1802
+ * structure for the dictionary that is read-optimized.
1803
+ *
1804
+ * This feature enables the use of that different structure.
1805
+ *
1806
+ * Note that some of the members of the ZSTD_compressionParameters struct have
1807
+ * different semantics and constraints in the dedicated search structure. It is
1808
+ * highly recommended that you simply set a compression level in the CCtxParams
1809
+ * you pass into the CDict creation call, and avoid messing with the cParams
1810
+ * directly.
1811
+ *
1812
+ * Effects:
1813
+ *
1814
+ * This will only have any effect when the selected ZSTD_strategy
1815
+ * implementation supports this feature. Currently, that's limited to
1816
+ * ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2.
1817
+ *
1818
+ * Note that this means that the CDict tables can no longer be copied into the
1819
+ * CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be
1820
+ * usable. The dictionary can only be attached or reloaded.
1821
+ *
1822
+ * In general, you should expect compression to be faster--sometimes very much
1823
+ * so--and CDict creation to be slightly slower. Eventually, we will probably
1824
+ * make this mode the default.
1825
+ */
1826
+ #define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8
1827
+
1828
+ /* ZSTD_c_stableInBuffer
1829
+ * Experimental parameter.
1830
+ * Default is 0 == disabled. Set to 1 to enable.
1831
+ *
1832
+ * Tells the compressor that the ZSTD_inBuffer will ALWAYS be the same
1833
+ * between calls, except for the modifications that zstd makes to pos (the
1834
+ * caller must not modify pos). This is checked by the compressor, and
1835
+ * compression will fail if it ever changes. This means the only flush
1836
+ * mode that makes sense is ZSTD_e_end, so zstd will error if ZSTD_e_end
1837
+ * is not used. The data in the ZSTD_inBuffer in the range [src, src + pos)
1838
+ * MUST not be modified during compression or you will get data corruption.
1839
+ *
1840
+ * When this flag is enabled zstd won't allocate an input window buffer,
1841
+ * because the user guarantees it can reference the ZSTD_inBuffer until
1842
+ * the frame is complete. But, it will still allocate an output buffer
1843
+ * large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also
1844
+ * avoid the memcpy() from the input buffer to the input window buffer.
1845
+ *
1846
+ * NOTE: ZSTD_compressStream2() will error if ZSTD_e_end is not used.
1847
+ * That means this flag cannot be used with ZSTD_compressStream().
1848
+ *
1849
+ * NOTE: So long as the ZSTD_inBuffer always points to valid memory, using
1850
+ * this flag is ALWAYS memory safe, and will never access out-of-bounds
1851
+ * memory. However, compression WILL fail if you violate the preconditions.
1852
+ *
1853
+ * WARNING: The data in the ZSTD_inBuffer in the range [dst, dst + pos) MUST
1854
+ * not be modified during compression or you will get data corruption. This
1855
+ * is because zstd needs to reference data in the ZSTD_inBuffer to find
1856
+ * matches. Normally zstd maintains its own window buffer for this purpose,
1857
+ * but passing this flag tells zstd to use the user provided buffer.
1858
+ */
1859
+ #define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9
1860
+
1861
+ /* ZSTD_c_stableOutBuffer
1862
+ * Experimental parameter.
1863
+ * Default is 0 == disabled. Set to 1 to enable.
1864
+ *
1865
+ * Tells he compressor that the ZSTD_outBuffer will not be resized between
1866
+ * calls. Specifically: (out.size - out.pos) will never grow. This gives the
1867
+ * compressor the freedom to say: If the compressed data doesn't fit in the
1868
+ * output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to
1869
+ * always decompress directly into the output buffer, instead of decompressing
1870
+ * into an internal buffer and copying to the output buffer.
1871
+ *
1872
+ * When this flag is enabled zstd won't allocate an output buffer, because
1873
+ * it can write directly to the ZSTD_outBuffer. It will still allocate the
1874
+ * input window buffer (see ZSTD_c_stableInBuffer).
1875
+ *
1876
+ * Zstd will check that (out.size - out.pos) never grows and return an error
1877
+ * if it does. While not strictly necessary, this should prevent surprises.
1878
+ */
1879
+ #define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
1880
+
1881
+ /* ZSTD_c_blockDelimiters
1882
+ * Default is 0 == ZSTD_sf_noBlockDelimiters.
1883
+ *
1884
+ * For use with sequence compression API: ZSTD_compressSequences().
1885
+ *
1886
+ * Designates whether or not the given array of ZSTD_Sequence contains block delimiters
1887
+ * and last literals, which are defined as sequences with offset == 0 and matchLength == 0.
1888
+ * See the definition of ZSTD_Sequence for more specifics.
1889
+ */
1890
+ #define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
1891
+
1892
+ /* ZSTD_c_validateSequences
1893
+ * Default is 0 == disabled. Set to 1 to enable sequence validation.
1894
+ *
1895
+ * For use with sequence compression API: ZSTD_compressSequences().
1896
+ * Designates whether or not we validate sequences provided to ZSTD_compressSequences()
1897
+ * during function execution.
1898
+ *
1899
+ * Without validation, providing a sequence that does not conform to the zstd spec will cause
1900
+ * undefined behavior, and may produce a corrupted block.
1901
+ *
1902
+ * With validation enabled, a if sequence is invalid (see doc/zstd_compression_format.md for
1903
+ * specifics regarding offset/matchlength requirements) then the function will bail out and
1904
+ * return an error.
1905
+ *
1906
+ */
1907
+ #define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
1908
+
1909
+ /* ZSTD_c_useBlockSplitter
1910
+ * Controlled with ZSTD_paramSwitch_e enum.
1911
+ * Default is ZSTD_ps_auto.
1912
+ * Set to ZSTD_ps_disable to never use block splitter.
1913
+ * Set to ZSTD_ps_enable to always use block splitter.
1914
+ *
1915
+ * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1916
+ * block splitting based on the compression parameters.
1917
+ */
1918
+ #define ZSTD_c_useBlockSplitter ZSTD_c_experimentalParam13
1919
+
1920
+ /* ZSTD_c_useRowMatchFinder
1921
+ * Controlled with ZSTD_paramSwitch_e enum.
1922
+ * Default is ZSTD_ps_auto.
1923
+ * Set to ZSTD_ps_disable to never use row-based matchfinder.
1924
+ * Set to ZSTD_ps_enable to force usage of row-based matchfinder.
1925
+ *
1926
+ * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1927
+ * the row-based matchfinder based on support for SIMD instructions and the window log.
1928
+ * Note that this only pertains to compression strategies: greedy, lazy, and lazy2
1929
+ */
1930
+ #define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14
1931
+
1932
+ /* ZSTD_c_deterministicRefPrefix
1933
+ * Default is 0 == disabled. Set to 1 to enable.
1934
+ *
1935
+ * Zstd produces different results for prefix compression when the prefix is
1936
+ * directly adjacent to the data about to be compressed vs. when it isn't.
1937
+ * This is because zstd detects that the two buffers are contiguous and it can
1938
+ * use a more efficient match finding algorithm. However, this produces different
1939
+ * results than when the two buffers are non-contiguous. This flag forces zstd
1940
+ * to always load the prefix in non-contiguous mode, even if it happens to be
1941
+ * adjacent to the data, to guarantee determinism.
1942
+ *
1943
+ * If you really care about determinism when using a dictionary or prefix,
1944
+ * like when doing delta compression, you should select this option. It comes
1945
+ * at a speed penalty of about ~2.5% if the dictionary and data happened to be
1946
+ * contiguous, and is free if they weren't contiguous. We don't expect that
1947
+ * intentionally making the dictionary and data contiguous will be worth the
1948
+ * cost to memcpy() the data.
1949
+ */
1950
+ #define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
1951
+
1511
1952
  /*! ZSTD_CCtx_getParameter() :
1512
1953
  * Get the requested compression parameter value, selected by enum ZSTD_cParameter,
1513
1954
  * and store it into int* value.
1514
1955
  * @return : 0, or an error code (which can be tested with ZSTD_isError()).
1515
1956
  */
1516
- ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
1957
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
1517
1958
 
1518
1959
 
1519
1960
  /*! ZSTD_CCtx_params :
@@ -1528,45 +1969,47 @@ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param
1528
1969
  * These parameters will be applied to
1529
1970
  * all subsequent frames.
1530
1971
  * - ZSTD_compressStream2() : Do compression using the CCtx.
1531
- * - ZSTD_freeCCtxParams() : Free the memory.
1972
+ * - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer.
1532
1973
  *
1533
1974
  * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
1534
1975
  * for static allocation of CCtx for single-threaded compression.
1535
1976
  */
1536
- ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
1537
- ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
1977
+ ZSTDLIB_STATIC_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
1978
+ ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */
1538
1979
 
1539
1980
  /*! ZSTD_CCtxParams_reset() :
1540
1981
  * Reset params to default values.
1541
1982
  */
1542
- ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
1983
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
1543
1984
 
1544
1985
  /*! ZSTD_CCtxParams_init() :
1545
1986
  * Initializes the compression parameters of cctxParams according to
1546
1987
  * compression level. All other parameters are reset to their default values.
1547
1988
  */
1548
- ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
1989
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
1549
1990
 
1550
1991
  /*! ZSTD_CCtxParams_init_advanced() :
1551
1992
  * Initializes the compression and frame parameters of cctxParams according to
1552
1993
  * params. All other parameters are reset to their default values.
1553
1994
  */
1554
- ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
1995
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
1555
1996
 
1556
- /*! ZSTD_CCtxParams_setParameter() :
1997
+ /*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+
1557
1998
  * Similar to ZSTD_CCtx_setParameter.
1558
1999
  * Set one compression parameter, selected by enum ZSTD_cParameter.
1559
- * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams().
1560
- * @result : 0, or an error code (which can be tested with ZSTD_isError()).
2000
+ * Parameters must be applied to a ZSTD_CCtx using
2001
+ * ZSTD_CCtx_setParametersUsingCCtxParams().
2002
+ * @result : a code representing success or failure (which can be tested with
2003
+ * ZSTD_isError()).
1561
2004
  */
1562
- ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
2005
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
1563
2006
 
1564
2007
  /*! ZSTD_CCtxParams_getParameter() :
1565
2008
  * Similar to ZSTD_CCtx_getParameter.
1566
2009
  * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
1567
2010
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1568
2011
  */
1569
- ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
2012
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
1570
2013
 
1571
2014
  /*! ZSTD_CCtx_setParametersUsingCCtxParams() :
1572
2015
  * Apply a set of ZSTD_CCtx_params to the compression context.
@@ -1575,7 +2018,7 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_c
1575
2018
  * if nbWorkers>=1, new parameters will be picked up at next job,
1576
2019
  * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated).
1577
2020
  */
1578
- ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
2021
+ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
1579
2022
  ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
1580
2023
 
1581
2024
  /*! ZSTD_compressStream2_simpleArgs() :
@@ -1584,7 +2027,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
1584
2027
  * This variant might be helpful for binders from dynamic languages
1585
2028
  * which have troubles handling structures containing memory pointers.
1586
2029
  */
1587
- ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs (
2030
+ ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs (
1588
2031
  ZSTD_CCtx* cctx,
1589
2032
  void* dst, size_t dstCapacity, size_t* dstPos,
1590
2033
  const void* src, size_t srcSize, size_t* srcPos,
@@ -1600,33 +2043,33 @@ ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs (
1600
2043
  * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
1601
2044
  * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
1602
2045
  * Note 3 : Skippable Frame Identifiers are considered valid. */
1603
- ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
2046
+ ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
1604
2047
 
1605
2048
  /*! ZSTD_createDDict_byReference() :
1606
2049
  * Create a digested dictionary, ready to start decompression operation without startup delay.
1607
2050
  * Dictionary content is referenced, and therefore stays in dictBuffer.
1608
2051
  * It is important that dictBuffer outlives DDict,
1609
2052
  * it must remain read accessible throughout the lifetime of DDict */
1610
- ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
2053
+ ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
1611
2054
 
1612
2055
  /*! ZSTD_DCtx_loadDictionary_byReference() :
1613
2056
  * Same as ZSTD_DCtx_loadDictionary(),
1614
2057
  * but references `dict` content instead of copying it into `dctx`.
1615
2058
  * This saves memory if `dict` remains around.,
1616
2059
  * However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */
1617
- ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
2060
+ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
1618
2061
 
1619
2062
  /*! ZSTD_DCtx_loadDictionary_advanced() :
1620
2063
  * Same as ZSTD_DCtx_loadDictionary(),
1621
2064
  * but gives direct control over
1622
2065
  * how to load the dictionary (by copy ? by reference ?)
1623
2066
  * and how to interpret it (automatic ? force raw mode ? full mode only ?). */
1624
- ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
2067
+ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1625
2068
 
1626
2069
  /*! ZSTD_DCtx_refPrefix_advanced() :
1627
2070
  * Same as ZSTD_DCtx_refPrefix(), but gives finer control over
1628
2071
  * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
1629
- ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
2072
+ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1630
2073
 
1631
2074
  /*! ZSTD_DCtx_setMaxWindowSize() :
1632
2075
  * Refuses allocating internal buffers for frames requiring a window size larger than provided limit.
@@ -1635,20 +2078,95 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* pre
1635
2078
  * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT)
1636
2079
  * @return : 0, or an error code (which can be tested using ZSTD_isError()).
1637
2080
  */
1638
- ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
2081
+ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
2082
+
2083
+ /*! ZSTD_DCtx_getParameter() :
2084
+ * Get the requested decompression parameter value, selected by enum ZSTD_dParameter,
2085
+ * and store it into int* value.
2086
+ * @return : 0, or an error code (which can be tested with ZSTD_isError()).
2087
+ */
2088
+ ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
1639
2089
 
1640
2090
  /* ZSTD_d_format
1641
2091
  * experimental parameter,
1642
2092
  * allowing selection between ZSTD_format_e input compression formats
1643
2093
  */
1644
2094
  #define ZSTD_d_format ZSTD_d_experimentalParam1
2095
+ /* ZSTD_d_stableOutBuffer
2096
+ * Experimental parameter.
2097
+ * Default is 0 == disabled. Set to 1 to enable.
2098
+ *
2099
+ * Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same
2100
+ * between calls, except for the modifications that zstd makes to pos (the
2101
+ * caller must not modify pos). This is checked by the decompressor, and
2102
+ * decompression will fail if it ever changes. Therefore the ZSTD_outBuffer
2103
+ * MUST be large enough to fit the entire decompressed frame. This will be
2104
+ * checked when the frame content size is known. The data in the ZSTD_outBuffer
2105
+ * in the range [dst, dst + pos) MUST not be modified during decompression
2106
+ * or you will get data corruption.
2107
+ *
2108
+ * When this flags is enabled zstd won't allocate an output buffer, because
2109
+ * it can write directly to the ZSTD_outBuffer, but it will still allocate
2110
+ * an input buffer large enough to fit any compressed block. This will also
2111
+ * avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer.
2112
+ * If you need to avoid the input buffer allocation use the buffer-less
2113
+ * streaming API.
2114
+ *
2115
+ * NOTE: So long as the ZSTD_outBuffer always points to valid memory, using
2116
+ * this flag is ALWAYS memory safe, and will never access out-of-bounds
2117
+ * memory. However, decompression WILL fail if you violate the preconditions.
2118
+ *
2119
+ * WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST
2120
+ * not be modified during decompression or you will get data corruption. This
2121
+ * is because zstd needs to reference data in the ZSTD_outBuffer to regenerate
2122
+ * matches. Normally zstd maintains its own buffer for this purpose, but passing
2123
+ * this flag tells zstd to use the user provided buffer.
2124
+ */
2125
+ #define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
2126
+
2127
+ /* ZSTD_d_forceIgnoreChecksum
2128
+ * Experimental parameter.
2129
+ * Default is 0 == disabled. Set to 1 to enable
2130
+ *
2131
+ * Tells the decompressor to skip checksum validation during decompression, regardless
2132
+ * of whether checksumming was specified during compression. This offers some
2133
+ * slight performance benefits, and may be useful for debugging.
2134
+ * Param has values of type ZSTD_forceIgnoreChecksum_e
2135
+ */
2136
+ #define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
2137
+
2138
+ /* ZSTD_d_refMultipleDDicts
2139
+ * Experimental parameter.
2140
+ * Default is 0 == disabled. Set to 1 to enable
2141
+ *
2142
+ * If enabled and dctx is allocated on the heap, then additional memory will be allocated
2143
+ * to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
2144
+ * using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
2145
+ * store all references. At decompression time, the appropriate dictID is selected
2146
+ * from the set of DDicts based on the dictID in the frame.
2147
+ *
2148
+ * Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
2149
+ *
2150
+ * Param has values of byte ZSTD_refMultipleDDicts_e
2151
+ *
2152
+ * WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory
2153
+ * allocation for the hash table. ZSTD_freeDCtx() also frees this memory.
2154
+ * Memory is allocated as per ZSTD_DCtx::customMem.
2155
+ *
2156
+ * Although this function allocates memory for the table, the user is still responsible for
2157
+ * memory management of the underlying ZSTD_DDict* themselves.
2158
+ */
2159
+ #define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4
2160
+
1645
2161
 
1646
2162
  /*! ZSTD_DCtx_setFormat() :
2163
+ * This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter().
1647
2164
  * Instruct the decoder context about what kind of data to decode next.
1648
2165
  * This instruction is mandatory to decode data without a fully-formed header,
1649
2166
  * such ZSTD_f_zstd1_magicless for example.
1650
2167
  * @return : 0, or an error code (which can be tested using ZSTD_isError()). */
1651
- ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
2168
+ ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
2169
+ size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
1652
2170
 
1653
2171
  /*! ZSTD_decompressStream_simpleArgs() :
1654
2172
  * Same as ZSTD_decompressStream(),
@@ -1656,7 +2174,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
1656
2174
  * This can be helpful for binders from dynamic languages
1657
2175
  * which have troubles handling structures containing memory pointers.
1658
2176
  */
1659
- ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
2177
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs (
1660
2178
  ZSTD_DCtx* dctx,
1661
2179
  void* dst, size_t dstCapacity, size_t* dstPos,
1662
2180
  const void* src, size_t srcSize, size_t* srcPos);
@@ -1670,8 +2188,9 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
1670
2188
  ********************************************************************/
1671
2189
 
1672
2190
  /*===== Advanced Streaming compression functions =====*/
1673
- /**! ZSTD_initCStream_srcSize() :
1674
- * This function is deprecated, and equivalent to:
2191
+
2192
+ /*! ZSTD_initCStream_srcSize() :
2193
+ * This function is DEPRECATED, and equivalent to:
1675
2194
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1676
2195
  * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
1677
2196
  * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
@@ -1680,15 +2199,15 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
1680
2199
  * pledgedSrcSize must be correct. If it is not known at init time, use
1681
2200
  * ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs,
1682
2201
  * "0" also disables frame content size field. It may be enabled in the future.
1683
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2202
+ * This prototype will generate compilation warnings.
1684
2203
  */
1685
- ZSTDLIB_API size_t
1686
- ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
2204
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2205
+ size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
1687
2206
  int compressionLevel,
1688
2207
  unsigned long long pledgedSrcSize);
1689
2208
 
1690
- /**! ZSTD_initCStream_usingDict() :
1691
- * This function is deprecated, and is equivalent to:
2209
+ /*! ZSTD_initCStream_usingDict() :
2210
+ * This function is DEPRECATED, and is equivalent to:
1692
2211
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1693
2212
  * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
1694
2213
  * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize);
@@ -1697,15 +2216,15 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
1697
2216
  * dict == NULL or dictSize < 8, in which case no dict is used.
1698
2217
  * Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if
1699
2218
  * it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.
1700
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2219
+ * This prototype will generate compilation warnings.
1701
2220
  */
1702
- ZSTDLIB_API size_t
1703
- ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
2221
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2222
+ size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
1704
2223
  const void* dict, size_t dictSize,
1705
2224
  int compressionLevel);
1706
2225
 
1707
- /**! ZSTD_initCStream_advanced() :
1708
- * This function is deprecated, and is approximately equivalent to:
2226
+ /*! ZSTD_initCStream_advanced() :
2227
+ * This function is DEPRECATED, and is approximately equivalent to:
1709
2228
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1710
2229
  * // Pseudocode: Set each zstd parameter and leave the rest as-is.
1711
2230
  * for ((param, value) : params) {
@@ -1717,25 +2236,26 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
1717
2236
  * dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy.
1718
2237
  * pledgedSrcSize must be correct.
1719
2238
  * If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN.
1720
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2239
+ * This prototype will generate compilation warnings.
1721
2240
  */
1722
- ZSTDLIB_API size_t
1723
- ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
2241
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2242
+ size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
1724
2243
  const void* dict, size_t dictSize,
1725
2244
  ZSTD_parameters params,
1726
2245
  unsigned long long pledgedSrcSize);
1727
2246
 
1728
- /**! ZSTD_initCStream_usingCDict() :
1729
- * This function is deprecated, and equivalent to:
2247
+ /*! ZSTD_initCStream_usingCDict() :
2248
+ * This function is DEPRECATED, and equivalent to:
1730
2249
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1731
2250
  * ZSTD_CCtx_refCDict(zcs, cdict);
1732
2251
  *
1733
2252
  * note : cdict will just be referenced, and must outlive compression session
1734
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2253
+ * This prototype will generate compilation warnings.
1735
2254
  */
1736
- ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
2255
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2256
+ size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
1737
2257
 
1738
- /**! ZSTD_initCStream_usingCDict_advanced() :
2258
+ /*! ZSTD_initCStream_usingCDict_advanced() :
1739
2259
  * This function is DEPRECATED, and is approximately equivalent to:
1740
2260
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1741
2261
  * // Pseudocode: Set each zstd frame parameter and leave the rest as-is.
@@ -1748,18 +2268,21 @@ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDi
1748
2268
  * same as ZSTD_initCStream_usingCDict(), with control over frame parameters.
1749
2269
  * pledgedSrcSize must be correct. If srcSize is not known at init time, use
1750
2270
  * value ZSTD_CONTENTSIZE_UNKNOWN.
1751
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2271
+ * This prototype will generate compilation warnings.
1752
2272
  */
1753
- ZSTDLIB_API size_t
1754
- ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
2273
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2274
+ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
1755
2275
  const ZSTD_CDict* cdict,
1756
2276
  ZSTD_frameParameters fParams,
1757
2277
  unsigned long long pledgedSrcSize);
1758
2278
 
1759
2279
  /*! ZSTD_resetCStream() :
1760
- * This function is deprecated, and is equivalent to:
2280
+ * This function is DEPRECATED, and is equivalent to:
1761
2281
  * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
1762
2282
  * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
2283
+ * Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but
2284
+ * ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be
2285
+ * explicitly specified.
1763
2286
  *
1764
2287
  * start a new frame, using same parameters from previous frame.
1765
2288
  * This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
@@ -1769,9 +2292,10 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
1769
2292
  * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
1770
2293
  * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
1771
2294
  * @return : 0, or an error code (which can be tested using ZSTD_isError())
1772
- * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
2295
+ * This prototype will generate compilation warnings.
1773
2296
  */
1774
- ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
2297
+ ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2298
+ size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
1775
2299
 
1776
2300
 
1777
2301
  typedef struct {
@@ -1789,7 +2313,7 @@ typedef struct {
1789
2313
  * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
1790
2314
  * Aggregates progression inside active worker threads.
1791
2315
  */
1792
- ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
2316
+ ZSTDLIB_STATIC_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
1793
2317
 
1794
2318
  /*! ZSTD_toFlushNow() :
1795
2319
  * Tell how many bytes are ready to be flushed immediately.
@@ -1804,11 +2328,12 @@ ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx
1804
2328
  * therefore flush speed is limited by production speed of oldest job
1805
2329
  * irrespective of the speed of concurrent (and newer) jobs.
1806
2330
  */
1807
- ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
2331
+ ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
1808
2332
 
1809
2333
 
1810
2334
  /*===== Advanced Streaming decompression functions =====*/
1811
- /**
2335
+
2336
+ /*!
1812
2337
  * This function is deprecated, and is equivalent to:
1813
2338
  *
1814
2339
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1817,9 +2342,9 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
1817
2342
  * note: no dictionary will be used if dict == NULL or dictSize < 8
1818
2343
  * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
1819
2344
  */
1820
- ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
2345
+ ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
1821
2346
 
1822
- /**
2347
+ /*!
1823
2348
  * This function is deprecated, and is equivalent to:
1824
2349
  *
1825
2350
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1828,9 +2353,9 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dic
1828
2353
  * note : ddict is referenced, it must outlive decompression session
1829
2354
  * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
1830
2355
  */
1831
- ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
2356
+ ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
1832
2357
 
1833
- /**
2358
+ /*!
1834
2359
  * This function is deprecated, and is equivalent to:
1835
2360
  *
1836
2361
  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
@@ -1838,7 +2363,7 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDi
1838
2363
  * re-use decompression parameters from previous init; saves dictionary loading
1839
2364
  * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
1840
2365
  */
1841
- ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
2366
+ ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
1842
2367
 
1843
2368
 
1844
2369
  /*********************************************************************
@@ -1857,8 +2382,7 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
1857
2382
  ZSTD_CCtx object can be re-used multiple times within successive compression operations.
1858
2383
 
1859
2384
  Start by initializing a context.
1860
- Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
1861
- or ZSTD_compressBegin_advanced(), for finer parameter control.
2385
+ Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
1862
2386
  It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
1863
2387
 
1864
2388
  Then, consume your input using ZSTD_compressContinue().
@@ -1881,18 +2405,20 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
1881
2405
  */
1882
2406
 
1883
2407
  /*===== Buffer-less streaming compression functions =====*/
1884
- ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
1885
- ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
1886
- 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 */
1887
- ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
1888
- 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 */
1889
- 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 */
1890
-
1891
- ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1892
- ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1893
-
1894
-
1895
- /*-
2408
+ ZSTDLIB_STATIC_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
2409
+ ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
2410
+ ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
2411
+ ZSTDLIB_STATIC_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 */
2412
+
2413
+ ZSTDLIB_STATIC_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2414
+ ZSTDLIB_STATIC_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2415
+
2416
+ /* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */
2417
+ ZSTD_DEPRECATED("use advanced API to access custom parameters")
2418
+ 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 */
2419
+ ZSTD_DEPRECATED("use advanced API to access custom parameters")
2420
+ 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 */
2421
+ /**
1896
2422
  Buffer-less streaming decompression (synchronous mode)
1897
2423
 
1898
2424
  A ZSTD_DCtx object is required to track streaming operations.
@@ -1982,24 +2508,24 @@ typedef struct {
1982
2508
  * @return : 0, `zfhPtr` is correctly filled,
1983
2509
  * >0, `srcSize` is too small, value is wanted `srcSize` amount,
1984
2510
  * or an error code, which can be tested using ZSTD_isError() */
1985
- ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
2511
+ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
1986
2512
  /*! ZSTD_getFrameHeader_advanced() :
1987
2513
  * same as ZSTD_getFrameHeader(),
1988
2514
  * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
1989
- ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
1990
- ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
2515
+ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
2516
+ ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
1991
2517
 
1992
- ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
1993
- ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
1994
- ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
2518
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
2519
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
2520
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
1995
2521
 
1996
- ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
1997
- ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2522
+ ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
2523
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1998
2524
 
1999
2525
  /* misc */
2000
- ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
2526
+ ZSTDLIB_STATIC_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
2001
2527
  typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
2002
- ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
2528
+ ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
2003
2529
 
2004
2530
 
2005
2531
 
@@ -2036,10 +2562,10 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
2036
2562
  */
2037
2563
 
2038
2564
  /*===== Raw zstd block functions =====*/
2039
- ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
2040
- ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2041
- ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2042
- ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
2565
+ ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
2566
+ ZSTDLIB_STATIC_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2567
+ ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2568
+ ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
2043
2569
 
2044
2570
 
2045
2571
  #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */