extzstd 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.ja +5 -0
  3. data/README.md +5 -5
  4. data/contrib/zstd/CONTRIBUTING.md +42 -0
  5. data/contrib/zstd/LICENSE-examples +11 -0
  6. data/contrib/zstd/Makefile +315 -0
  7. data/contrib/zstd/NEWS +261 -0
  8. data/contrib/zstd/PATENTS +33 -0
  9. data/contrib/zstd/README.md +121 -41
  10. data/contrib/zstd/TESTING.md +44 -0
  11. data/contrib/zstd/appveyor.yml +178 -0
  12. data/contrib/zstd/circle.yml +75 -0
  13. data/contrib/zstd/lib/BUCK +186 -0
  14. data/contrib/zstd/lib/Makefile +163 -0
  15. data/contrib/zstd/lib/README.md +77 -0
  16. data/contrib/zstd/{common → lib/common}/bitstream.h +7 -4
  17. data/contrib/zstd/{common → lib/common}/entropy_common.c +19 -23
  18. data/contrib/zstd/{common → lib/common}/error_private.c +0 -0
  19. data/contrib/zstd/{common → lib/common}/error_private.h +0 -0
  20. data/contrib/zstd/{common → lib/common}/fse.h +94 -34
  21. data/contrib/zstd/{common → lib/common}/fse_decompress.c +18 -19
  22. data/contrib/zstd/{common → lib/common}/huf.h +52 -20
  23. data/contrib/zstd/{common → lib/common}/mem.h +17 -13
  24. data/contrib/zstd/lib/common/pool.c +194 -0
  25. data/contrib/zstd/lib/common/pool.h +56 -0
  26. data/contrib/zstd/lib/common/threading.c +80 -0
  27. data/contrib/zstd/lib/common/threading.h +104 -0
  28. data/contrib/zstd/{common → lib/common}/xxhash.c +3 -1
  29. data/contrib/zstd/{common → lib/common}/xxhash.h +11 -15
  30. data/contrib/zstd/{common → lib/common}/zstd_common.c +1 -11
  31. data/contrib/zstd/{common → lib/common}/zstd_errors.h +16 -2
  32. data/contrib/zstd/{common → lib/common}/zstd_internal.h +17 -1
  33. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +138 -91
  34. data/contrib/zstd/{compress → lib/compress}/huf_compress.c +218 -67
  35. data/contrib/zstd/{compress → lib/compress}/zstd_compress.c +231 -108
  36. data/contrib/zstd/{compress → lib/compress}/zstd_opt.h +44 -25
  37. data/contrib/zstd/lib/compress/zstdmt_compress.c +739 -0
  38. data/contrib/zstd/lib/compress/zstdmt_compress.h +78 -0
  39. data/contrib/zstd/{decompress → lib/decompress}/huf_decompress.c +28 -23
  40. data/contrib/zstd/{decompress → lib/decompress}/zstd_decompress.c +814 -176
  41. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +60 -39
  42. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  43. data/contrib/zstd/lib/deprecated/zbuff_compress.c +145 -0
  44. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +74 -0
  45. data/contrib/zstd/lib/dictBuilder/cover.c +1029 -0
  46. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +0 -0
  47. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
  48. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +68 -18
  49. data/contrib/zstd/lib/dictBuilder/zdict.h +201 -0
  50. data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +122 -7
  51. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +34 -3
  52. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +8 -0
  53. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +45 -12
  54. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +8 -0
  55. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +45 -12
  56. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +8 -0
  57. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +56 -33
  58. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +8 -0
  59. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +45 -18
  60. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +7 -0
  61. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +43 -16
  62. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +7 -0
  63. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +57 -23
  64. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +8 -0
  65. data/contrib/zstd/lib/libzstd.pc.in +14 -0
  66. data/contrib/zstd/{zstd.h → lib/zstd.h} +206 -71
  67. data/ext/depend +2 -0
  68. data/ext/extconf.rb +4 -4
  69. data/ext/extzstd.c +1 -1
  70. data/ext/zstd_common.c +5 -5
  71. data/ext/zstd_compress.c +3 -3
  72. data/ext/zstd_decompress.c +2 -2
  73. data/ext/zstd_dictbuilder.c +2 -2
  74. data/ext/zstd_legacy_v01.c +1 -1
  75. data/ext/zstd_legacy_v02.c +1 -1
  76. data/ext/zstd_legacy_v03.c +1 -1
  77. data/ext/zstd_legacy_v04.c +1 -1
  78. data/ext/zstd_legacy_v05.c +1 -1
  79. data/ext/zstd_legacy_v06.c +1 -1
  80. data/ext/zstd_legacy_v07.c +1 -1
  81. data/gemstub.rb +9 -5
  82. data/lib/extzstd/version.rb +1 -1
  83. metadata +73 -51
  84. data/contrib/zstd/compress/zbuff_compress.c +0 -319
  85. data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
  86. data/contrib/zstd/dictBuilder/zdict.h +0 -111
@@ -7,26 +7,29 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  */
9
9
 
10
- #ifndef ZSTD_H_235446
11
- #define ZSTD_H_235446
12
-
13
10
  #if defined (__cplusplus)
14
11
  extern "C" {
15
12
  #endif
16
13
 
14
+ #ifndef ZSTD_H_235446
15
+ #define ZSTD_H_235446
16
+
17
17
  /* ====== Dependency ======*/
18
18
  #include <stddef.h> /* size_t */
19
19
 
20
20
 
21
- /* ====== Export for Windows ======*/
22
- /*
23
- * ZSTD_DLL_EXPORT :
24
- * Enable exporting of functions when building a Windows DLL
25
- */
26
- #if defined(_WIN32) && defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
27
- # define ZSTDLIB_API __declspec(dllexport)
21
+ /* ===== ZSTDLIB_API : control library symbols visibility ===== */
22
+ #if defined(__GNUC__) && (__GNUC__ >= 4)
23
+ # define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
24
+ #else
25
+ # define ZSTDLIB_VISIBILITY
26
+ #endif
27
+ #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
28
+ # define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
29
+ #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
30
+ # 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.*/
28
31
  #else
29
- # define ZSTDLIB_API
32
+ # define ZSTDLIB_API ZSTDLIB_VISIBILITY
30
33
  #endif
31
34
 
32
35
 
@@ -36,7 +39,7 @@ extern "C" {
36
39
  zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios
37
40
  at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and
38
41
  decompression functions. The library supports compression levels from 1 up to ZSTD_maxCLevel() which is 22.
39
- Levels >= 20, labelled `--ultra`, should be used with caution, as they require more memory.
42
+ Levels >= 20, labeled `--ultra`, should be used with caution, as they require more memory.
40
43
  Compression can be done in:
41
44
  - a single step (described as Simple API)
42
45
  - a single step, reusing a context (described as Explicit memory management)
@@ -51,11 +54,9 @@ extern "C" {
51
54
  *********************************************************************************************************/
52
55
 
53
56
  /*------ Version ------*/
54
- ZSTDLIB_API unsigned ZSTD_versionNumber (void); /**< returns version number of ZSTD */
55
-
56
57
  #define ZSTD_VERSION_MAJOR 1
57
58
  #define ZSTD_VERSION_MINOR 1
58
- #define ZSTD_VERSION_RELEASE 1
59
+ #define ZSTD_VERSION_RELEASE 4
59
60
 
60
61
  #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
61
62
  #define ZSTD_QUOTE(str) #str
@@ -63,6 +64,7 @@ ZSTDLIB_API unsigned ZSTD_versionNumber (void); /**< returns version number of
63
64
  #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
64
65
 
65
66
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
67
+ ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< library version number; to be used when checking dll version */
66
68
 
67
69
 
68
70
  /***************************************
@@ -72,21 +74,30 @@ ZSTDLIB_API unsigned ZSTD_versionNumber (void); /**< returns version number of
72
74
  Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
73
75
  Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
74
76
  @return : compressed size written into `dst` (<= `dstCapacity),
75
- or an error code if it fails (which can be tested using ZSTD_isError()) */
77
+ or an error code if it fails (which can be tested using ZSTD_isError()). */
76
78
  ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
77
79
  const void* src, size_t srcSize,
78
80
  int compressionLevel);
79
81
 
80
82
  /*! ZSTD_decompress() :
81
- `compressedSize` : must be the _exact_ size of a single compressed frame.
83
+ `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
82
84
  `dstCapacity` is an upper bound of originalSize.
83
85
  If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
84
86
  @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
85
- or an errorCode if it fails (which can be tested using ZSTD_isError()) */
87
+ or an errorCode if it fails (which can be tested using ZSTD_isError()). */
86
88
  ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
87
89
  const void* src, size_t compressedSize);
88
90
 
89
91
  /*! ZSTD_getDecompressedSize() :
92
+ * NOTE: This function is planned to be obsolete, in favour of ZSTD_getFrameContentSize.
93
+ * ZSTD_getFrameContentSize functions the same way, returning the decompressed size of a single
94
+ * frame, but distinguishes empty frames from frames with an unknown size, or errors.
95
+ *
96
+ * Additionally, ZSTD_findDecompressedSize can be used instead. It can handle multiple
97
+ * concatenated frames in one buffer, and so is more general.
98
+ * As a result however, it requires more computation and entire frames to be passed to it,
99
+ * as opposed to ZSTD_getFrameContentSize which requires only a single frame's header.
100
+ *
90
101
  * 'src' is the start of a zstd compressed frame.
91
102
  * @return : content size to be decompressed, as a 64-bits value _if known_, 0 otherwise.
92
103
  * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
@@ -116,25 +127,29 @@ ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readab
116
127
  * Explicit memory management
117
128
  ***************************************/
118
129
  /*= Compression context
119
- * When compressing many messages / blocks,
130
+ * When compressing many times,
120
131
  * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
121
- * This will make the situation much easier for the system's memory.
132
+ * This will make workload friendlier for system's memory.
122
133
  * Use one context per thread for parallel execution in multi-threaded environments. */
123
134
  typedef struct ZSTD_CCtx_s ZSTD_CCtx;
124
135
  ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
125
136
  ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
126
137
 
127
138
  /*! ZSTD_compressCCtx() :
128
- Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()) */
139
+ Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
129
140
  ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel);
130
141
 
131
- /*= Decompression context */
142
+ /*= Decompression context
143
+ * When decompressing many times,
144
+ * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
145
+ * This will make workload friendlier for system's memory.
146
+ * Use one context per thread for parallel execution in multi-threaded environments. */
132
147
  typedef struct ZSTD_DCtx_s ZSTD_DCtx;
133
148
  ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
134
149
  ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
135
150
 
136
151
  /*! ZSTD_decompressDCtx() :
137
- * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */
152
+ * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()). */
138
153
  ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
139
154
 
140
155
 
@@ -143,7 +158,8 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t dstCapa
143
158
  ***************************/
144
159
  /*! ZSTD_compress_usingDict() :
145
160
  * Compression using a predefined Dictionary (see dictBuilder/zdict.h).
146
- * Note : This function load the dictionary, resulting in significant startup delay. */
161
+ * Note : This function loads the dictionary, resulting in significant startup delay.
162
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
147
163
  ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
148
164
  void* dst, size_t dstCapacity,
149
165
  const void* src, size_t srcSize,
@@ -153,7 +169,8 @@ ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
153
169
  /*! ZSTD_decompress_usingDict() :
154
170
  * Decompression using a predefined Dictionary (see dictBuilder/zdict.h).
155
171
  * Dictionary must be identical to the one used during compression.
156
- * Note : This function load the dictionary, resulting in significant startup delay */
172
+ * Note : This function loads the dictionary, resulting in significant startup delay.
173
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
157
174
  ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
158
175
  void* dst, size_t dstCapacity,
159
176
  const void* src, size_t srcSize,
@@ -169,17 +186,17 @@ typedef struct ZSTD_CDict_s ZSTD_CDict;
169
186
  * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
170
187
  * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
171
188
  * ZSTD_CDict can be created once and used by multiple threads concurrently, as its usage is read-only.
172
- * `dict` can be released after ZSTD_CDict creation */
173
- ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionLevel);
189
+ * `dictBuffer` can be released after ZSTD_CDict creation, as its content is copied within CDict */
190
+ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, int compressionLevel);
174
191
 
175
192
  /*! ZSTD_freeCDict() :
176
- * Function frees memory allocated by ZSTD_createCDict() */
193
+ * Function frees memory allocated by ZSTD_createCDict(). */
177
194
  ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
178
195
 
179
196
  /*! ZSTD_compress_usingCDict() :
180
197
  * Compression using a digested Dictionary.
181
198
  * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
182
- * Note that compression level is decided during dictionary creation */
199
+ * Note that compression level is decided during dictionary creation. */
183
200
  ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
184
201
  void* dst, size_t dstCapacity,
185
202
  const void* src, size_t srcSize,
@@ -190,15 +207,15 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
190
207
 
191
208
  /*! ZSTD_createDDict() :
192
209
  * Create a digested dictionary, ready to start decompression operation without startup delay.
193
- * `dict` can be released after creation */
194
- ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize);
210
+ * dictBuffer can be released after DDict creation, as its content is copied inside DDict */
211
+ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
195
212
 
196
213
  /*! ZSTD_freeDDict() :
197
214
  * Function frees memory allocated with ZSTD_createDDict() */
198
215
  ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
199
216
 
200
217
  /*! ZSTD_decompress_usingDDict() :
201
- * Decompression using a digested Dictionary
218
+ * Decompression using a digested Dictionary.
202
219
  * Faster startup than ZSTD_decompress_usingDict(), recommended when same dictionary is used multiple times. */
203
220
  ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
204
221
  void* dst, size_t dstCapacity,
@@ -236,20 +253,20 @@ typedef struct ZSTD_outBuffer_s {
236
253
  *
237
254
  * Start a new compression by initializing ZSTD_CStream.
238
255
  * Use ZSTD_initCStream() to start a new compression operation.
239
- * Use ZSTD_initCStream_usingDict() for a compression which requires a dictionary.
256
+ * Use ZSTD_initCStream_usingDict() or ZSTD_initCStream_usingCDict() for a compression which requires a dictionary (experimental section)
240
257
  *
241
258
  * Use ZSTD_compressStream() repetitively to consume input stream.
242
259
  * The function will automatically update both `pos` fields.
243
260
  * Note that it may not consume the entire input, in which case `pos < size`,
244
261
  * and it's up to the caller to present again remaining data.
245
262
  * @return : a size hint, preferred nb of bytes to use as input for next function call
246
- * (it's just a hint, to help latency a little, any other value will work fine)
247
- * (note : the size hint is guaranteed to be <= ZSTD_CStreamInSize() )
248
263
  * or an error code, which can be tested using ZSTD_isError().
264
+ * Note 1 : it's just a hint, to help latency a little, any other value will work fine.
265
+ * Note 2 : size hint is guaranteed to be <= ZSTD_CStreamInSize()
249
266
  *
250
- * At any moment, it's possible to flush whatever data remains within buffer, using ZSTD_flushStream().
267
+ * At any moment, it's possible to flush whatever data remains within internal buffer, using ZSTD_flushStream().
251
268
  * `output->pos` will be updated.
252
- * Note some content might still be left within internal buffer if `output->size` is too small.
269
+ * Note that some content might still be left within internal buffer if `output->size` is too small.
253
270
  * @return : nb of bytes still present within internal buffer (0 if it's empty)
254
271
  * or an error code, which can be tested using ZSTD_isError().
255
272
  *
@@ -258,15 +275,17 @@ typedef struct ZSTD_outBuffer_s {
258
275
  * The epilogue is required for decoders to consider a frame completed.
259
276
  * Similar to ZSTD_flushStream(), it may not be able to flush the full content if `output->size` is too small.
260
277
  * In which case, call again ZSTD_endStream() to complete the flush.
261
- * @return : nb of bytes still present within internal buffer (0 if it's empty)
278
+ * @return : nb of bytes still present within internal buffer (0 if it's empty, hence compression completed)
262
279
  * or an error code, which can be tested using ZSTD_isError().
263
280
  *
264
281
  * *******************************************************************/
265
282
 
266
- /*===== Streaming compression functions ======*/
267
283
  typedef struct ZSTD_CStream_s ZSTD_CStream;
284
+ /*===== ZSTD_CStream management functions =====*/
268
285
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
269
286
  ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
287
+
288
+ /*===== Streaming compression functions =====*/
270
289
  ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
271
290
  ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
272
291
  ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
@@ -295,23 +314,27 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
295
314
  * If `output.pos < output.size`, decoder has flushed everything it could.
296
315
  * @return : 0 when a frame is completely decoded and fully flushed,
297
316
  * an error code, which can be tested using ZSTD_isError(),
298
- * any other value > 0, which means there is still some work to do to complete the frame.
299
- * The return value is a suggested next input size (just an hint, to help latency).
317
+ * any other value > 0, which means there is still some decoding to do to complete current frame.
318
+ * The return value is a suggested next input size (a hint to improve latency) that will never load more than the current frame.
300
319
  * *******************************************************************************/
301
320
 
302
- /*===== Streaming decompression functions =====*/
303
321
  typedef struct ZSTD_DStream_s ZSTD_DStream;
322
+ /*===== ZSTD_DStream management functions =====*/
304
323
  ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
305
324
  ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
325
+
326
+ /*===== Streaming decompression functions =====*/
306
327
  ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
307
328
  ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
308
329
 
309
330
  ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */
310
331
  ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */
311
332
 
333
+ #endif /* ZSTD_H_235446 */
312
334
 
313
335
 
314
- #ifdef ZSTD_STATIC_LINKING_ONLY
336
+ #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
337
+ #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
315
338
 
316
339
  /****************************************************************************************
317
340
  * START OF ADVANCED AND EXPERIMENTAL FUNCTIONS
@@ -322,12 +345,15 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
322
345
  * ***************************************************************************************/
323
346
 
324
347
  /* --- Constants ---*/
325
- #define ZSTD_MAGICNUMBER 0xFD2FB528 /* v0.8 */
348
+ #define ZSTD_MAGICNUMBER 0xFD2FB528 /* >= v0.8.0 */
326
349
  #define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U
327
350
 
328
- #define ZSTD_WINDOWLOG_MAX_32 25
351
+ #define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
352
+ #define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
353
+
354
+ #define ZSTD_WINDOWLOG_MAX_32 27
329
355
  #define ZSTD_WINDOWLOG_MAX_64 27
330
- #define ZSTD_WINDOWLOG_MAX ((U32)(MEM_32bits() ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
356
+ #define ZSTD_WINDOWLOG_MAX ((unsigned)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
331
357
  #define ZSTD_WINDOWLOG_MIN 10
332
358
  #define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX
333
359
  #define ZSTD_HASHLOG_MIN 6
@@ -342,8 +368,9 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
342
368
  #define ZSTD_TARGETLENGTH_MAX 999
343
369
 
344
370
  #define ZSTD_FRAMEHEADERSIZE_MAX 18 /* for static allocation */
371
+ #define ZSTD_FRAMEHEADERSIZE_MIN 6
345
372
  static const size_t ZSTD_frameHeaderSize_prefix = 5;
346
- static const size_t ZSTD_frameHeaderSize_min = 6;
373
+ static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN;
347
374
  static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX;
348
375
  static const size_t ZSTD_skippableHeaderSize = 8; /* magic number + skippable frame length */
349
376
 
@@ -362,9 +389,9 @@ typedef struct {
362
389
  } ZSTD_compressionParameters;
363
390
 
364
391
  typedef struct {
365
- unsigned contentSizeFlag; /**< 1: content size will be in frame header (if known). */
366
- unsigned checksumFlag; /**< 1: will generate a 22-bits checksum at end of frame, to be used for error detection by decompressor */
367
- unsigned noDictIDFlag; /**< 1: no dict ID will be saved into frame header (if dictionary compression) */
392
+ unsigned contentSizeFlag; /**< 1: content size will be in frame header (when known) */
393
+ unsigned checksumFlag; /**< 1: generate a 32-bits checksum at end of frame, for error detection */
394
+ unsigned noDictIDFlag; /**< 1: no dictID will be saved into frame header (if dictionary compression) */
368
395
  } ZSTD_frameParameters;
369
396
 
370
397
  typedef struct {
@@ -377,6 +404,54 @@ typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
377
404
  typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
378
405
  typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
379
406
 
407
+ /***************************************
408
+ * Compressed size functions
409
+ ***************************************/
410
+
411
+ /*! ZSTD_findFrameCompressedSize() :
412
+ * `src` should point to the start of a ZSTD encoded frame or skippable frame
413
+ * `srcSize` must be at least as large as the frame
414
+ * @return : the compressed size of the frame pointed to by `src`, suitable to pass to
415
+ * `ZSTD_decompress` or similar, or an error code if given invalid input. */
416
+ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
417
+
418
+ /***************************************
419
+ * Decompressed size functions
420
+ ***************************************/
421
+ /*! ZSTD_getFrameContentSize() :
422
+ * `src` should point to the start of a ZSTD encoded frame
423
+ * `srcSize` must be at least as large as the frame header. A value greater than or equal
424
+ * to `ZSTD_frameHeaderSize_max` is guaranteed to be large enough in all cases.
425
+ * @return : decompressed size of the frame pointed to be `src` if known, otherwise
426
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
427
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */
428
+ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
429
+
430
+ /*! ZSTD_findDecompressedSize() :
431
+ * `src` should point the start of a series of ZSTD encoded and/or skippable frames
432
+ * `srcSize` must be the _exact_ size of this series
433
+ * (i.e. there should be a frame boundary exactly `srcSize` bytes after `src`)
434
+ * @return : the decompressed size of all data in the contained frames, as a 64-bit value _if known_
435
+ * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
436
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
437
+ *
438
+ * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
439
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
440
+ * In which case, it's necessary to use streaming mode to decompress data.
441
+ * Optionally, application can still use ZSTD_decompress() while relying on implied limits.
442
+ * (For example, data may be necessarily cut into blocks <= 16 KB).
443
+ * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
444
+ * note 3 : decompressed size can be very large (64-bits value),
445
+ * potentially larger than what local system can handle as a single memory segment.
446
+ * In which case, it's necessary to use streaming mode to decompress data.
447
+ * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
448
+ * Always ensure result fits within application's authorized limits.
449
+ * Each application can set its own limits.
450
+ * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
451
+ * read each contained frame header. This is efficient as most of the data is skipped,
452
+ * however it does mean that all frame data must be present and valid. */
453
+ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
454
+
380
455
 
381
456
  /***************************************
382
457
  * Advanced compression functions
@@ -394,24 +469,39 @@ ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
394
469
  * Gives the amount of memory used by a given ZSTD_CCtx */
395
470
  ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
396
471
 
472
+ typedef enum {
473
+ ZSTD_p_forceWindow, /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0) */
474
+ ZSTD_p_forceRawDict /* Force loading dictionary in "content-only" mode (no header analysis) */
475
+ } ZSTD_CCtxParameter;
476
+ /*! ZSTD_setCCtxParameter() :
477
+ * Set advanced parameters, selected through enum ZSTD_CCtxParameter
478
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()) */
479
+ ZSTDLIB_API size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value);
480
+
481
+ /*! ZSTD_createCDict_byReference() :
482
+ * Create a digested dictionary for compression
483
+ * Dictionary content is simply referenced, and therefore stays in dictBuffer.
484
+ * It is important that dictBuffer outlives CDict, it must remain read accessible throughout the lifetime of CDict */
485
+ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
486
+
397
487
  /*! ZSTD_createCDict_advanced() :
398
488
  * Create a ZSTD_CDict using external alloc and free, and customized compression parameters */
399
- ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
489
+ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, unsigned byReference,
400
490
  ZSTD_parameters params, ZSTD_customMem customMem);
401
491
 
402
492
  /*! ZSTD_sizeof_CDict() :
403
493
  * Gives the amount of memory used by a given ZSTD_sizeof_CDict */
404
494
  ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
405
495
 
496
+ /*! ZSTD_getCParams() :
497
+ * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
498
+ * `estimatedSrcSize` value is optional, select 0 if not known */
499
+ ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
500
+
406
501
  /*! ZSTD_getParams() :
407
- * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of a `ZSTD_compressionParameters`.
502
+ * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
408
503
  * All fields of `ZSTD_frameParameters` are set to default (0) */
409
- ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSize, size_t dictSize);
410
-
411
- /*! ZSTD_getCParams() :
412
- * @return ZSTD_compressionParameters structure for a selected compression level and srcSize.
413
- * `srcSize` value is optional, select 0 if not known */
414
- ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSize, size_t dictSize);
504
+ ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
415
505
 
416
506
  /*! ZSTD_checkCParams() :
417
507
  * Ensure param values remain within authorized range */
@@ -433,6 +523,13 @@ ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* ctx,
433
523
 
434
524
  /*--- Advanced decompression functions ---*/
435
525
 
526
+ /*! ZSTD_isFrame() :
527
+ * Tells if the content of `buffer` starts with a valid Frame Identifier.
528
+ * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
529
+ * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
530
+ * Note 3 : Skippable Frame Identifiers are considered valid. */
531
+ ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
532
+
436
533
  /*! ZSTD_estimateDCtxSize() :
437
534
  * Gives the potential amount of memory allocated to create a ZSTD_DCtx */
438
535
  ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
@@ -445,10 +542,45 @@ ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
445
542
  * Gives the amount of memory used by a given ZSTD_DCtx */
446
543
  ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
447
544
 
545
+ /*! ZSTD_createDDict_byReference() :
546
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
547
+ * Dictionary content is simply referenced, and therefore stays in dictBuffer.
548
+ * It is important that dictBuffer outlives DDict, it must remain read accessible throughout the lifetime of DDict */
549
+ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
550
+
551
+ /*! ZSTD_createDDict_advanced() :
552
+ * Create a ZSTD_DDict using external alloc and free, optionally by reference */
553
+ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
554
+ unsigned byReference, ZSTD_customMem customMem);
555
+
448
556
  /*! ZSTD_sizeof_DDict() :
449
557
  * Gives the amount of memory used by a given ZSTD_DDict */
450
558
  ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
451
559
 
560
+ /*! ZSTD_getDictID_fromDict() :
561
+ * Provides the dictID stored within dictionary.
562
+ * if @return == 0, the dictionary is not conformant with Zstandard specification.
563
+ * It can still be loaded, but as a content-only dictionary. */
564
+ ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
565
+
566
+ /*! ZSTD_getDictID_fromDDict() :
567
+ * Provides the dictID of the dictionary loaded into `ddict`.
568
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
569
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
570
+ ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
571
+
572
+ /*! ZSTD_getDictID_fromFrame() :
573
+ * Provides the dictID required to decompressed the frame stored within `src`.
574
+ * If @return == 0, the dictID could not be decoded.
575
+ * This could for one of the following reasons :
576
+ * - The frame does not require a dictionary to be decoded (most common case).
577
+ * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information.
578
+ * Note : this use case also happens when using a non-conformant dictionary.
579
+ * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
580
+ * - This is not a Zstandard frame.
581
+ * When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */
582
+ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
583
+
452
584
 
453
585
  /********************************************************************
454
586
  * Advanced streaming functions
@@ -456,18 +588,19 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
456
588
 
457
589
  /*===== Advanced Streaming compression functions =====*/
458
590
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
459
- ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel);
591
+ ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
592
+ ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
460
593
  ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
461
- ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */
594
+ ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
462
595
  ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
463
- ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before */
596
+ ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before. note: pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
464
597
  ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
465
598
 
466
599
 
467
600
  /*===== Advanced Streaming decompression functions =====*/
468
- typedef enum { ZSTDdsp_maxWindowSize } ZSTD_DStreamParameter_e;
601
+ typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e;
469
602
  ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
470
- ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
603
+ ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
471
604
  ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue);
472
605
  ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict will just be referenced, and must outlive decompression session */
473
606
  ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */
@@ -507,17 +640,18 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
507
640
  In which case, it will "discard" the relevant memory section from its history.
508
641
 
509
642
  Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
510
- It's possible to use a NULL,0 src content, in which case, it will write a final empty block to end the frame,
511
- Without last block mark, frames will be considered unfinished (broken) by decoders.
643
+ It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
644
+ Without last block mark, frames will be considered unfinished (corrupted) by decoders.
512
645
 
513
- You can then reuse `ZSTD_CCtx` (ZSTD_compressBegin()) to compress some new frame.
646
+ `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress some new frame.
514
647
  */
515
648
 
516
649
  /*===== Buffer-less streaming compression functions =====*/
517
650
  ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
518
651
  ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
519
- ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
520
- ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize);
652
+ ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
653
+ ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize can be 0, indicating unknown size. if it is non-zero, it must be accurate. for 0 size frames, use compressBegin_advanced */
654
+ ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize can be 0, indicating unknown size. if it is non-zero, it must be accurate. for 0 size frames, use compressBegin_advanced */
521
655
  ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
522
656
  ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
523
657
 
@@ -577,6 +711,9 @@ ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapaci
577
711
  c) Frame Content - any content (User Data) of length equal to Frame Size
578
712
  For skippable frames ZSTD_decompressContinue() always returns 0.
579
713
  For skippable frames ZSTD_getFrameParams() returns fparamsPtr->windowLog==0 what means that a frame is skippable.
714
+ Note : If fparamsPtr->frameContentSize==0, it is ambiguous: the frame might actually be a Zstd encoded frame with no content.
715
+ For purposes of decompression, it is valid in both cases to skip the frame using
716
+ ZSTD_findFrameCompressedSize to find its size in bytes.
580
717
  It also returns Frame Size as fparamsPtr->frameContentSize.
581
718
  */
582
719
 
@@ -631,10 +768,8 @@ ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCa
631
768
  ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful for uncompressed blocks */
632
769
 
633
770
 
634
- #endif /* ZSTD_STATIC_LINKING_ONLY */
771
+ #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
635
772
 
636
773
  #if defined (__cplusplus)
637
774
  }
638
775
  #endif
639
-
640
- #endif /* ZSTD_H_235446 */
data/ext/depend ADDED
@@ -0,0 +1,2 @@
1
+ extzstd.o: extzstd.c extzstd.h
2
+ extzstd_stream.o: extzstd_stream.c extzstd.h extzstd_nogvls.h
data/ext/extconf.rb CHANGED
@@ -4,10 +4,10 @@ require "mkmf"
4
4
 
5
5
  $INCFLAGS = %w(
6
6
  -I$(srcdir)/../contrib
7
- -I$(srcdir)/../contrib/zstd
8
- -I$(srcdir)/../contrib/zstd/common
9
- -I$(srcdir)/../contrib/zstd/dictBuilder
10
- -I$(srcdir)/../contrib/zstd/legacy
7
+ -I$(srcdir)/../contrib/zstd/lib
8
+ -I$(srcdir)/../contrib/zstd/lib/common
9
+ -I$(srcdir)/../contrib/zstd/lib/dictBuilder
10
+ -I$(srcdir)/../contrib/zstd/lib/legacy
11
11
  ).join(" ") + " #$INCFLAGS"
12
12
 
13
13
  #dir = File.dirname(__FILE__).gsub(/[\[\{\?\*]/, "[\\0]")
data/ext/extzstd.c CHANGED
@@ -1,5 +1,5 @@
1
1
  #include "extzstd.h"
2
- #include <zstd/common/mem.h>
2
+ #include <zstd/lib/common/mem.h>
3
3
  #include <zstd_errors.h>
4
4
  #include <zdict.h>
5
5
 
data/ext/zstd_common.c CHANGED
@@ -1,8 +1,8 @@
1
1
  #define ZSTD_LEGACY_SUPPORT 1
2
2
  #define MEM_MODULE 1
3
3
 
4
- #include "../contrib/zstd/common/entropy_common.c"
5
- #include "../contrib/zstd/common/error_private.c"
6
- #include "../contrib/zstd/common/fse_decompress.c"
7
- #include "../contrib/zstd/common/xxhash.c"
8
- #include "../contrib/zstd/common/zstd_common.c"
4
+ #include "../contrib/zstd/lib/common/entropy_common.c"
5
+ #include "../contrib/zstd/lib/common/error_private.c"
6
+ #include "../contrib/zstd/lib/common/fse_decompress.c"
7
+ #include "../contrib/zstd/lib/common/xxhash.c"
8
+ #include "../contrib/zstd/lib/common/zstd_common.c"
data/ext/zstd_compress.c CHANGED
@@ -1,6 +1,6 @@
1
1
  #define ZSTD_LEGACY_SUPPORT 1
2
2
  #define MEM_MODULE 1
3
3
 
4
- #include "../contrib/zstd/compress/fse_compress.c"
5
- #include "../contrib/zstd/compress/huf_compress.c"
6
- #include "../contrib/zstd/compress/zstd_compress.c"
4
+ #include "../contrib/zstd/lib/compress/fse_compress.c"
5
+ #include "../contrib/zstd/lib/compress/huf_compress.c"
6
+ #include "../contrib/zstd/lib/compress/zstd_compress.c"
@@ -1,5 +1,5 @@
1
1
  #define ZSTD_LEGACY_SUPPORT 1
2
2
  #define MEM_MODULE 1
3
3
 
4
- #include "../contrib/zstd/decompress/zstd_decompress.c"
5
- #include "../contrib/zstd/decompress/huf_decompress.c"
4
+ #include "../contrib/zstd/lib/decompress/zstd_decompress.c"
5
+ #include "../contrib/zstd/lib/decompress/huf_decompress.c"
@@ -1,5 +1,5 @@
1
1
  #define ZSTD_LEGACY_SUPPORT 1
2
2
  #define MEM_MODULE 1
3
3
 
4
- #include "../contrib/zstd/dictBuilder/zdict.c"
5
- #include "../contrib/zstd/dictBuilder/divsufsort.c"
4
+ #include "../contrib/zstd/lib/dictBuilder/zdict.c"
5
+ #include "../contrib/zstd/lib/dictBuilder/divsufsort.c"
@@ -1 +1 @@
1
- #include "../contrib/zstd/legacy/zstd_v01.c"
1
+ #include "../contrib/zstd/lib/legacy/zstd_v01.c"
@@ -1 +1 @@
1
- #include "../contrib/zstd/legacy/zstd_v02.c"
1
+ #include "../contrib/zstd/lib/legacy/zstd_v02.c"
@@ -1 +1 @@
1
- #include "../contrib/zstd/legacy/zstd_v03.c"
1
+ #include "../contrib/zstd/lib/legacy/zstd_v03.c"
@@ -1 +1 @@
1
- #include "../contrib/zstd/legacy/zstd_v04.c"
1
+ #include "../contrib/zstd/lib/legacy/zstd_v04.c"