zstd 1.1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +64 -0
  7. data/Rakefile +19 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/exe/zstd +3 -0
  11. data/ext/zstd/extconf.rb +20 -0
  12. data/ext/zstd/libzstd/.gitignore +2 -0
  13. data/ext/zstd/libzstd/LICENSE +1262 -0
  14. data/ext/zstd/libzstd/Makefile +133 -0
  15. data/ext/zstd/libzstd/PATENTS +1272 -0
  16. data/ext/zstd/libzstd/README.md +77 -0
  17. data/ext/zstd/libzstd/common/bitstream.h +414 -0
  18. data/ext/zstd/libzstd/common/entropy_common.c +227 -0
  19. data/ext/zstd/libzstd/common/error_private.c +43 -0
  20. data/ext/zstd/libzstd/common/error_private.h +76 -0
  21. data/ext/zstd/libzstd/common/fse.h +668 -0
  22. data/ext/zstd/libzstd/common/fse_decompress.c +329 -0
  23. data/ext/zstd/libzstd/common/huf.h +238 -0
  24. data/ext/zstd/libzstd/common/mem.h +372 -0
  25. data/ext/zstd/libzstd/common/xxhash.c +867 -0
  26. data/ext/zstd/libzstd/common/xxhash.h +309 -0
  27. data/ext/zstd/libzstd/common/zstd_common.c +77 -0
  28. data/ext/zstd/libzstd/common/zstd_errors.h +60 -0
  29. data/ext/zstd/libzstd/common/zstd_internal.h +270 -0
  30. data/ext/zstd/libzstd/compress/fse_compress.c +850 -0
  31. data/ext/zstd/libzstd/compress/huf_compress.c +609 -0
  32. data/ext/zstd/libzstd/compress/zstd_compress.c +3291 -0
  33. data/ext/zstd/libzstd/compress/zstd_opt.h +919 -0
  34. data/ext/zstd/libzstd/decompress/huf_decompress.c +885 -0
  35. data/ext/zstd/libzstd/decompress/zstd_decompress.c +2154 -0
  36. data/ext/zstd/libzstd/deprecated/zbuff.h +210 -0
  37. data/ext/zstd/libzstd/deprecated/zbuff_compress.c +145 -0
  38. data/ext/zstd/libzstd/deprecated/zbuff_decompress.c +74 -0
  39. data/ext/zstd/libzstd/dictBuilder/divsufsort.c +1913 -0
  40. data/ext/zstd/libzstd/dictBuilder/divsufsort.h +67 -0
  41. data/ext/zstd/libzstd/dictBuilder/zdict.c +1012 -0
  42. data/ext/zstd/libzstd/dictBuilder/zdict.h +111 -0
  43. data/ext/zstd/libzstd/dll/example/Makefile +47 -0
  44. data/ext/zstd/libzstd/dll/example/README.md +69 -0
  45. data/ext/zstd/libzstd/dll/example/build_package.bat +17 -0
  46. data/ext/zstd/libzstd/dll/example/fullbench-dll.sln +25 -0
  47. data/ext/zstd/libzstd/dll/example/fullbench-dll.vcxproj +179 -0
  48. data/ext/zstd/libzstd/dll/libzstd.def +86 -0
  49. data/ext/zstd/libzstd/legacy/zstd_legacy.h +259 -0
  50. data/ext/zstd/libzstd/legacy/zstd_v01.c +2095 -0
  51. data/ext/zstd/libzstd/legacy/zstd_v01.h +80 -0
  52. data/ext/zstd/libzstd/legacy/zstd_v02.c +3518 -0
  53. data/ext/zstd/libzstd/legacy/zstd_v02.h +79 -0
  54. data/ext/zstd/libzstd/legacy/zstd_v03.c +3159 -0
  55. data/ext/zstd/libzstd/legacy/zstd_v03.h +79 -0
  56. data/ext/zstd/libzstd/legacy/zstd_v04.c +3795 -0
  57. data/ext/zstd/libzstd/legacy/zstd_v04.h +128 -0
  58. data/ext/zstd/libzstd/legacy/zstd_v05.c +4056 -0
  59. data/ext/zstd/libzstd/legacy/zstd_v05.h +149 -0
  60. data/ext/zstd/libzstd/legacy/zstd_v06.c +4167 -0
  61. data/ext/zstd/libzstd/legacy/zstd_v06.h +159 -0
  62. data/ext/zstd/libzstd/legacy/zstd_v07.c +4540 -0
  63. data/ext/zstd/libzstd/legacy/zstd_v07.h +173 -0
  64. data/ext/zstd/libzstd/libzstd.pc.in +14 -0
  65. data/ext/zstd/libzstd/zstd.h +673 -0
  66. data/ext/zstd/zstd.c +185 -0
  67. data/ext/zstd/zstd.h +7 -0
  68. data/lib/zstd/version.rb +3 -0
  69. data/lib/zstd.rb +6 -0
  70. data/zstd.gemspec +38 -0
  71. metadata +172 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+ /* ***************************************************************
11
+ * NOTES/WARNINGS
12
+ ******************************************************************/
13
+ /* The streaming API defined here is deprecated.
14
+ * Consider migrating towards ZSTD_compressStream() API in `zstd.h`
15
+ * See 'lib/README.md'.
16
+ *****************************************************************/
17
+
18
+
19
+ #if defined (__cplusplus)
20
+ extern "C" {
21
+ #endif
22
+
23
+ #ifndef ZSTD_BUFFERED_H_23987
24
+ #define ZSTD_BUFFERED_H_23987
25
+
26
+ /* *************************************
27
+ * Dependencies
28
+ ***************************************/
29
+ #include <stddef.h> /* size_t */
30
+ #include "zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
31
+
32
+
33
+ /* ***************************************************************
34
+ * Compiler specifics
35
+ *****************************************************************/
36
+ /* Deprecation warnings */
37
+ /* Should these warnings be a problem,
38
+ it is generally possible to disable them,
39
+ typically with -Wno-deprecated-declarations for gcc
40
+ or _CRT_SECURE_NO_WARNINGS in Visual.
41
+ Otherwise, it's also possible to define ZBUFF_DISABLE_DEPRECATE_WARNINGS */
42
+ #ifdef ZBUFF_DISABLE_DEPRECATE_WARNINGS
43
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
44
+ #else
45
+ # if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
46
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
47
+ # elif defined(__GNUC__) && (__GNUC__ >= 3)
48
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
49
+ # elif defined(_MSC_VER)
50
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
51
+ # else
52
+ # pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
53
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API
54
+ # endif
55
+ #endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
56
+
57
+
58
+ /* *************************************
59
+ * Streaming functions
60
+ ***************************************/
61
+ /* This is the easier "buffered" streaming API,
62
+ * using an internal buffer to lift all restrictions on user-provided buffers
63
+ * which can be any size, any place, for both input and output.
64
+ * ZBUFF and ZSTD are 100% interoperable,
65
+ * frames created by one can be decoded by the other one */
66
+
67
+ typedef ZSTD_CStream ZBUFF_CCtx;
68
+ ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
69
+ ZBUFF_DEPRECATED("use ZSTD_freeCStream") size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
70
+
71
+ ZBUFF_DEPRECATED("use ZSTD_initCStream") size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
72
+ ZBUFF_DEPRECATED("use ZSTD_initCStream_usingDict") size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
73
+
74
+ ZBUFF_DEPRECATED("use ZSTD_compressStream") size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
75
+ ZBUFF_DEPRECATED("use ZSTD_flushStream") size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
76
+ ZBUFF_DEPRECATED("use ZSTD_endStream") size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
77
+
78
+ /*-*************************************************
79
+ * Streaming compression - howto
80
+ *
81
+ * A ZBUFF_CCtx object is required to track streaming operation.
82
+ * Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
83
+ * ZBUFF_CCtx objects can be reused multiple times.
84
+ *
85
+ * Start by initializing ZBUF_CCtx.
86
+ * Use ZBUFF_compressInit() to start a new compression operation.
87
+ * Use ZBUFF_compressInitDictionary() for a compression which requires a dictionary.
88
+ *
89
+ * Use ZBUFF_compressContinue() repetitively to consume input stream.
90
+ * *srcSizePtr and *dstCapacityPtr can be any size.
91
+ * The function will report how many bytes were read or written within *srcSizePtr and *dstCapacityPtr.
92
+ * Note that it may not consume the entire input, in which case it's up to the caller to present again remaining data.
93
+ * The content of `dst` will be overwritten (up to *dstCapacityPtr) at each call, so save its content if it matters or change @dst .
94
+ * @return : a hint to preferred nb of bytes to use as input for next function call (it's just a hint, to improve latency)
95
+ * or an error code, which can be tested using ZBUFF_isError().
96
+ *
97
+ * At any moment, it's possible to flush whatever data remains within buffer, using ZBUFF_compressFlush().
98
+ * The nb of bytes written into `dst` will be reported into *dstCapacityPtr.
99
+ * Note that the function cannot output more than *dstCapacityPtr,
100
+ * therefore, some content might still be left into internal buffer if *dstCapacityPtr is too small.
101
+ * @return : nb of bytes still present into internal buffer (0 if it's empty)
102
+ * or an error code, which can be tested using ZBUFF_isError().
103
+ *
104
+ * ZBUFF_compressEnd() instructs to finish a frame.
105
+ * It will perform a flush and write frame epilogue.
106
+ * The epilogue is required for decoders to consider a frame completed.
107
+ * Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
108
+ * In which case, call again ZBUFF_compressFlush() to complete the flush.
109
+ * @return : nb of bytes still present into internal buffer (0 if it's empty)
110
+ * or an error code, which can be tested using ZBUFF_isError().
111
+ *
112
+ * Hint : _recommended buffer_ sizes (not compulsory) : ZBUFF_recommendedCInSize() / ZBUFF_recommendedCOutSize()
113
+ * input : ZBUFF_recommendedCInSize==128 KB block size is the internal unit, use this value to reduce intermediate stages (better latency)
114
+ * output : ZBUFF_recommendedCOutSize==ZSTD_compressBound(128 KB) + 3 + 3 : ensures it's always possible to write/flush/end a full block. Skip some buffering.
115
+ * By using both, it ensures that input will be entirely consumed, and output will always contain the result, reducing intermediate buffering.
116
+ * **************************************************/
117
+
118
+
119
+ typedef ZSTD_DStream ZBUFF_DCtx;
120
+ ZBUFF_DEPRECATED("use ZSTD_createDStream") ZBUFF_DCtx* ZBUFF_createDCtx(void);
121
+ ZBUFF_DEPRECATED("use ZSTD_freeDStream") size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
122
+
123
+ ZBUFF_DEPRECATED("use ZSTD_initDStream") size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
124
+ ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
125
+
126
+ ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
127
+ void* dst, size_t* dstCapacityPtr,
128
+ const void* src, size_t* srcSizePtr);
129
+
130
+ /*-***************************************************************************
131
+ * Streaming decompression howto
132
+ *
133
+ * A ZBUFF_DCtx object is required to track streaming operations.
134
+ * Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
135
+ * Use ZBUFF_decompressInit() to start a new decompression operation,
136
+ * or ZBUFF_decompressInitDictionary() if decompression requires a dictionary.
137
+ * Note that ZBUFF_DCtx objects can be re-init multiple times.
138
+ *
139
+ * Use ZBUFF_decompressContinue() repetitively to consume your input.
140
+ * *srcSizePtr and *dstCapacityPtr can be any size.
141
+ * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
142
+ * Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
143
+ * The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
144
+ * @return : 0 when a frame is completely decoded and fully flushed,
145
+ * 1 when there is still some data left within internal buffer to flush,
146
+ * >1 when more data is expected, with value being a suggested next input size (it's just a hint, which helps latency),
147
+ * or an error code, which can be tested using ZBUFF_isError().
148
+ *
149
+ * Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize() and ZBUFF_recommendedDOutSize()
150
+ * output : ZBUFF_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
151
+ * input : ZBUFF_recommendedDInSize == 128KB + 3;
152
+ * just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
153
+ * *******************************************************************************/
154
+
155
+
156
+ /* *************************************
157
+ * Tool functions
158
+ ***************************************/
159
+ ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
160
+ ZBUFF_DEPRECATED("use ZSTD_getErrorName") const char* ZBUFF_getErrorName(size_t errorCode);
161
+
162
+ /** Functions below provide recommended buffer sizes for Compression or Decompression operations.
163
+ * These sizes are just hints, they tend to offer better latency */
164
+ ZBUFF_DEPRECATED("use ZSTD_CStreamInSize") size_t ZBUFF_recommendedCInSize(void);
165
+ ZBUFF_DEPRECATED("use ZSTD_CStreamOutSize") size_t ZBUFF_recommendedCOutSize(void);
166
+ ZBUFF_DEPRECATED("use ZSTD_DStreamInSize") size_t ZBUFF_recommendedDInSize(void);
167
+ ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(void);
168
+
169
+ #endif /* ZSTD_BUFFERED_H_23987 */
170
+
171
+
172
+ #ifdef ZBUFF_STATIC_LINKING_ONLY
173
+ #ifndef ZBUFF_STATIC_H_30298098432
174
+ #define ZBUFF_STATIC_H_30298098432
175
+
176
+ /* ====================================================================================
177
+ * The definitions in this section are considered experimental.
178
+ * They should never be used in association with a dynamic library, as they may change in the future.
179
+ * They are provided for advanced usages.
180
+ * Use them only in association with static linking.
181
+ * ==================================================================================== */
182
+
183
+ /*--- Dependency ---*/
184
+ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
185
+ #include "zstd.h"
186
+
187
+
188
+ /*--- Custom memory allocator ---*/
189
+ /*! ZBUFF_createCCtx_advanced() :
190
+ * Create a ZBUFF compression context using external alloc and free functions */
191
+ ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
192
+
193
+ /*! ZBUFF_createDCtx_advanced() :
194
+ * Create a ZBUFF decompression context using external alloc and free functions */
195
+ ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
196
+
197
+
198
+ /*--- Advanced Streaming Initialization ---*/
199
+ ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
200
+ const void* dict, size_t dictSize,
201
+ ZSTD_parameters params, unsigned long long pledgedSrcSize);
202
+
203
+
204
+ #endif /* ZBUFF_STATIC_H_30298098432 */
205
+ #endif /* ZBUFF_STATIC_LINKING_ONLY */
206
+
207
+
208
+ #if defined (__cplusplus)
209
+ }
210
+ #endif
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+
11
+
12
+ /* *************************************
13
+ * Dependencies
14
+ ***************************************/
15
+ #define ZBUFF_STATIC_LINKING_ONLY
16
+ #include "zbuff.h"
17
+
18
+
19
+ /*-***********************************************************
20
+ * Streaming compression
21
+ *
22
+ * A ZBUFF_CCtx object is required to track streaming operation.
23
+ * Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
24
+ * Use ZBUFF_compressInit() to start a new compression operation.
25
+ * ZBUFF_CCtx objects can be reused multiple times.
26
+ *
27
+ * Use ZBUFF_compressContinue() repetitively to consume your input.
28
+ * *srcSizePtr and *dstCapacityPtr can be any size.
29
+ * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
30
+ * Note that it may not consume the entire input, in which case it's up to the caller to call again the function with remaining input.
31
+ * The content of dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change dst .
32
+ * @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
33
+ * or an error code, which can be tested using ZBUFF_isError().
34
+ *
35
+ * ZBUFF_compressFlush() can be used to instruct ZBUFF to compress and output whatever remains within its buffer.
36
+ * Note that it will not output more than *dstCapacityPtr.
37
+ * Therefore, some content might still be left into its internal buffer if dst buffer is too small.
38
+ * @return : nb of bytes still present into internal buffer (0 if it's empty)
39
+ * or an error code, which can be tested using ZBUFF_isError().
40
+ *
41
+ * ZBUFF_compressEnd() instructs to finish a frame.
42
+ * It will perform a flush and write frame epilogue.
43
+ * Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
44
+ * @return : nb of bytes still present into internal buffer (0 if it's empty)
45
+ * or an error code, which can be tested using ZBUFF_isError().
46
+ *
47
+ * Hint : recommended buffer sizes (not compulsory)
48
+ * input : ZSTD_BLOCKSIZE_MAX (128 KB), internal unit size, it improves latency to use this value.
49
+ * output : ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + ZBUFF_endFrameSize : ensures it's always possible to write/flush/end a full block at best speed.
50
+ * ***********************************************************/
51
+
52
+ ZBUFF_CCtx* ZBUFF_createCCtx(void)
53
+ {
54
+ return ZSTD_createCStream();
55
+ }
56
+
57
+ ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
58
+ {
59
+ return ZSTD_createCStream_advanced(customMem);
60
+ }
61
+
62
+ size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
63
+ {
64
+ return ZSTD_freeCStream(zbc);
65
+ }
66
+
67
+
68
+ /* ====== Initialization ====== */
69
+
70
+ size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
71
+ const void* dict, size_t dictSize,
72
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
73
+ {
74
+ return ZSTD_initCStream_advanced(zbc, dict, dictSize, params, pledgedSrcSize);
75
+ }
76
+
77
+
78
+ size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
79
+ {
80
+ return ZSTD_initCStream_usingDict(zbc, dict, dictSize, compressionLevel);
81
+ }
82
+
83
+ size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)
84
+ {
85
+ return ZSTD_initCStream(zbc, compressionLevel);
86
+ }
87
+
88
+ /* ====== Compression ====== */
89
+
90
+
91
+ size_t ZBUFF_compressContinue(ZBUFF_CCtx* zbc,
92
+ void* dst, size_t* dstCapacityPtr,
93
+ const void* src, size_t* srcSizePtr)
94
+ {
95
+ size_t result;
96
+ ZSTD_outBuffer outBuff;
97
+ ZSTD_inBuffer inBuff;
98
+ outBuff.dst = dst;
99
+ outBuff.pos = 0;
100
+ outBuff.size = *dstCapacityPtr;
101
+ inBuff.src = src;
102
+ inBuff.pos = 0;
103
+ inBuff.size = *srcSizePtr;
104
+ result = ZSTD_compressStream(zbc, &outBuff, &inBuff);
105
+ *dstCapacityPtr = outBuff.pos;
106
+ *srcSizePtr = inBuff.pos;
107
+ return result;
108
+ }
109
+
110
+
111
+
112
+ /* ====== Finalize ====== */
113
+
114
+ size_t ZBUFF_compressFlush(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
115
+ {
116
+ size_t result;
117
+ ZSTD_outBuffer outBuff;
118
+ outBuff.dst = dst;
119
+ outBuff.pos = 0;
120
+ outBuff.size = *dstCapacityPtr;
121
+ result = ZSTD_flushStream(zbc, &outBuff);
122
+ *dstCapacityPtr = outBuff.pos;
123
+ return result;
124
+ }
125
+
126
+
127
+ size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
128
+ {
129
+ size_t result;
130
+ ZSTD_outBuffer outBuff;
131
+ outBuff.dst = dst;
132
+ outBuff.pos = 0;
133
+ outBuff.size = *dstCapacityPtr;
134
+ result = ZSTD_endStream(zbc, &outBuff);
135
+ *dstCapacityPtr = outBuff.pos;
136
+ return result;
137
+ }
138
+
139
+
140
+
141
+ /* *************************************
142
+ * Tool functions
143
+ ***************************************/
144
+ size_t ZBUFF_recommendedCInSize(void) { return ZSTD_CStreamInSize(); }
145
+ size_t ZBUFF_recommendedCOutSize(void) { return ZSTD_CStreamOutSize(); }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+
11
+
12
+ /* *************************************
13
+ * Dependencies
14
+ ***************************************/
15
+ #define ZBUFF_STATIC_LINKING_ONLY
16
+ #include "zbuff.h"
17
+
18
+
19
+ ZBUFF_DCtx* ZBUFF_createDCtx(void)
20
+ {
21
+ return ZSTD_createDStream();
22
+ }
23
+
24
+ ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
25
+ {
26
+ return ZSTD_createDStream_advanced(customMem);
27
+ }
28
+
29
+ size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
30
+ {
31
+ return ZSTD_freeDStream(zbd);
32
+ }
33
+
34
+
35
+ /* *** Initialization *** */
36
+
37
+ size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
38
+ {
39
+ return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
40
+ }
41
+
42
+ size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
43
+ {
44
+ return ZSTD_initDStream(zbd);
45
+ }
46
+
47
+
48
+ /* *** Decompression *** */
49
+
50
+ size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
51
+ void* dst, size_t* dstCapacityPtr,
52
+ const void* src, size_t* srcSizePtr)
53
+ {
54
+ ZSTD_outBuffer outBuff;
55
+ ZSTD_inBuffer inBuff;
56
+ size_t result;
57
+ outBuff.dst = dst;
58
+ outBuff.pos = 0;
59
+ outBuff.size = *dstCapacityPtr;
60
+ inBuff.src = src;
61
+ inBuff.pos = 0;
62
+ inBuff.size = *srcSizePtr;
63
+ result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
64
+ *dstCapacityPtr = outBuff.pos;
65
+ *srcSizePtr = inBuff.pos;
66
+ return result;
67
+ }
68
+
69
+
70
+ /* *************************************
71
+ * Tool functions
72
+ ***************************************/
73
+ size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
74
+ size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }