extzstd 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -9,35 +9,52 @@
9
9
 
10
10
  /* ***************************************************************
11
11
  * NOTES/WARNINGS
12
- *****************************************************************/
13
- /* The streaming API defined here will soon be deprecated by the
14
- * new one in 'zstd.h'; consider migrating towards newer streaming
15
- * API. See 'lib/README.md'.
16
- *****************************************************************/
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
17
 
18
- #ifndef ZSTD_BUFFERED_H_23987
19
- #define ZSTD_BUFFERED_H_23987
20
18
 
21
19
  #if defined (__cplusplus)
22
20
  extern "C" {
23
21
  #endif
24
22
 
23
+ #ifndef ZSTD_BUFFERED_H_23987
24
+ #define ZSTD_BUFFERED_H_23987
25
+
25
26
  /* *************************************
26
27
  * Dependencies
27
28
  ***************************************/
28
29
  #include <stddef.h> /* size_t */
30
+ #include "zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
29
31
 
30
32
 
31
33
  /* ***************************************************************
32
34
  * Compiler specifics
33
35
  *****************************************************************/
34
- /* ZSTD_DLL_EXPORT :
35
- * Enable exporting of functions when building a Windows DLL */
36
- #if defined(_WIN32) && defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
37
- # define ZSTDLIB_API __declspec(dllexport)
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 */
38
44
  #else
39
- # define ZSTDLIB_API
40
- #endif
45
+ # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
46
+ # define ZBUFF_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
47
+ # elif (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
48
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
49
+ # elif defined(__GNUC__) && (__GNUC__ >= 3)
50
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
51
+ # elif defined(_MSC_VER)
52
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
53
+ # else
54
+ # pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
55
+ # define ZBUFF_DEPRECATED(message) ZSTDLIB_API
56
+ # endif
57
+ #endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
41
58
 
42
59
 
43
60
  /* *************************************
@@ -49,16 +66,16 @@ extern "C" {
49
66
  * ZBUFF and ZSTD are 100% interoperable,
50
67
  * frames created by one can be decoded by the other one */
51
68
 
52
- typedef struct ZBUFF_CCtx_s ZBUFF_CCtx;
53
- ZSTDLIB_API ZBUFF_CCtx* ZBUFF_createCCtx(void);
54
- ZSTDLIB_API size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
69
+ typedef ZSTD_CStream ZBUFF_CCtx;
70
+ ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
71
+ ZBUFF_DEPRECATED("use ZSTD_freeCStream") size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
55
72
 
56
- ZSTDLIB_API size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
57
- ZSTDLIB_API size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
73
+ ZBUFF_DEPRECATED("use ZSTD_initCStream") size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
74
+ ZBUFF_DEPRECATED("use ZSTD_initCStream_usingDict") size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
58
75
 
59
- ZSTDLIB_API size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
60
- ZSTDLIB_API size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
61
- ZSTDLIB_API size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
76
+ ZBUFF_DEPRECATED("use ZSTD_compressStream") size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
77
+ ZBUFF_DEPRECATED("use ZSTD_flushStream") size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
78
+ ZBUFF_DEPRECATED("use ZSTD_endStream") size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
62
79
 
63
80
  /*-*************************************************
64
81
  * Streaming compression - howto
@@ -101,14 +118,14 @@ ZSTDLIB_API size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCap
101
118
  * **************************************************/
102
119
 
103
120
 
104
- typedef struct ZBUFF_DCtx_s ZBUFF_DCtx;
105
- ZSTDLIB_API ZBUFF_DCtx* ZBUFF_createDCtx(void);
106
- ZSTDLIB_API size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
121
+ typedef ZSTD_DStream ZBUFF_DCtx;
122
+ ZBUFF_DEPRECATED("use ZSTD_createDStream") ZBUFF_DCtx* ZBUFF_createDCtx(void);
123
+ ZBUFF_DEPRECATED("use ZSTD_freeDStream") size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
107
124
 
108
- ZSTDLIB_API size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
109
- ZSTDLIB_API size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
125
+ ZBUFF_DEPRECATED("use ZSTD_initDStream") size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
126
+ ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
110
127
 
111
- ZSTDLIB_API size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
128
+ ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
112
129
  void* dst, size_t* dstCapacityPtr,
113
130
  const void* src, size_t* srcSizePtr);
114
131
 
@@ -141,18 +158,22 @@ ZSTDLIB_API size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
141
158
  /* *************************************
142
159
  * Tool functions
143
160
  ***************************************/
144
- ZSTDLIB_API unsigned ZBUFF_isError(size_t errorCode);
145
- ZSTDLIB_API const char* ZBUFF_getErrorName(size_t errorCode);
161
+ ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
162
+ ZBUFF_DEPRECATED("use ZSTD_getErrorName") const char* ZBUFF_getErrorName(size_t errorCode);
146
163
 
147
164
  /** Functions below provide recommended buffer sizes for Compression or Decompression operations.
148
165
  * These sizes are just hints, they tend to offer better latency */
149
- ZSTDLIB_API size_t ZBUFF_recommendedCInSize(void);
150
- ZSTDLIB_API size_t ZBUFF_recommendedCOutSize(void);
151
- ZSTDLIB_API size_t ZBUFF_recommendedDInSize(void);
152
- ZSTDLIB_API size_t ZBUFF_recommendedDOutSize(void);
166
+ ZBUFF_DEPRECATED("use ZSTD_CStreamInSize") size_t ZBUFF_recommendedCInSize(void);
167
+ ZBUFF_DEPRECATED("use ZSTD_CStreamOutSize") size_t ZBUFF_recommendedCOutSize(void);
168
+ ZBUFF_DEPRECATED("use ZSTD_DStreamInSize") size_t ZBUFF_recommendedDInSize(void);
169
+ ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(void);
170
+
171
+ #endif /* ZSTD_BUFFERED_H_23987 */
153
172
 
154
173
 
155
174
  #ifdef ZBUFF_STATIC_LINKING_ONLY
175
+ #ifndef ZBUFF_STATIC_H_30298098432
176
+ #define ZBUFF_STATIC_H_30298098432
156
177
 
157
178
  /* ====================================================================================
158
179
  * The definitions in this section are considered experimental.
@@ -169,23 +190,23 @@ ZSTDLIB_API size_t ZBUFF_recommendedDOutSize(void);
169
190
  /*--- Custom memory allocator ---*/
170
191
  /*! ZBUFF_createCCtx_advanced() :
171
192
  * Create a ZBUFF compression context using external alloc and free functions */
172
- ZSTDLIB_API ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
193
+ ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
173
194
 
174
195
  /*! ZBUFF_createDCtx_advanced() :
175
196
  * Create a ZBUFF decompression context using external alloc and free functions */
176
- ZSTDLIB_API ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
197
+ ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
177
198
 
178
199
 
179
200
  /*--- Advanced Streaming Initialization ---*/
180
- ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
201
+ ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
181
202
  const void* dict, size_t dictSize,
182
203
  ZSTD_parameters params, unsigned long long pledgedSrcSize);
183
204
 
184
- #endif /* ZBUFF_STATIC_LINKING_ONLY */
205
+
206
+ #endif /* ZBUFF_STATIC_H_30298098432 */
207
+ #endif /* ZBUFF_STATIC_LINKING_ONLY */
185
208
 
186
209
 
187
210
  #if defined (__cplusplus)
188
211
  }
189
212
  #endif
190
-
191
- #endif /* ZSTD_BUFFERED_H_23987 */
@@ -0,0 +1,26 @@
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
+ * Dependencies
12
+ ***************************************/
13
+ #include "error_private.h"
14
+ #include "zbuff.h"
15
+
16
+ /*-****************************************
17
+ * ZBUFF Error Management (deprecated)
18
+ ******************************************/
19
+
20
+ /*! ZBUFF_isError() :
21
+ * tells if a return value is an error code */
22
+ unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
23
+ /*! ZBUFF_getErrorName() :
24
+ * provides error code string from function result (useful for debugging) */
25
+ const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
26
+
@@ -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(); }