zstdlib 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/ext/zstdlib/extconf.rb +1 -1
  4. data/ext/zstdlib/ruby/zlib-3.0/zstdlib.c +4994 -0
  5. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/bitstream.h +25 -16
  6. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/compiler.h +118 -4
  7. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/cpu.h +1 -3
  8. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.c +1 -1
  9. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.h +12 -19
  10. data/ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c +362 -0
  11. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.c +2 -1
  12. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.h +3 -3
  13. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse.h +40 -12
  14. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse_decompress.c +139 -22
  15. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/huf.h +29 -7
  16. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/mem.h +69 -98
  17. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.c +23 -17
  18. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.h +2 -2
  19. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.c +6 -5
  20. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.h +0 -0
  21. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.c +20 -60
  22. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.h +2 -2
  23. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_common.c +10 -10
  24. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h +111 -0
  25. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_internal.h +105 -62
  26. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h +154 -0
  27. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/fse_compress.c +31 -24
  28. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.c +27 -29
  29. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.h +2 -2
  30. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/huf_compress.c +265 -126
  31. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress.c +2843 -728
  32. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_internal.h +305 -63
  33. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.c +8 -8
  34. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.h +1 -1
  35. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.c +29 -7
  36. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.h +1 -1
  37. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.c +22 -295
  38. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.h +1 -1
  39. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_cwksp.h +204 -67
  40. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.c +25 -25
  41. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.h +1 -1
  42. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.c +23 -23
  43. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.h +1 -1
  44. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c +2184 -0
  45. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h +125 -0
  46. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.c +314 -211
  47. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.h +9 -2
  48. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h +103 -0
  49. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.c +191 -46
  50. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.h +1 -1
  51. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstdmt_compress.c +93 -415
  52. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h +110 -0
  53. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/huf_decompress.c +342 -239
  54. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.c +9 -9
  55. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.h +2 -2
  56. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress.c +369 -87
  57. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.c +191 -75
  58. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.h +6 -3
  59. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_internal.h +27 -11
  60. data/ext/zstdlib/zstd-1.5.0/lib/zdict.h +452 -0
  61. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/zstd.h +568 -126
  62. data/ext/zstdlib/{zstd-1.4.5/lib/common → zstd-1.5.0/lib}/zstd_errors.h +2 -1
  63. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzclose.c +0 -0
  64. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzcompatibility.h +1 -1
  65. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzguts.h +0 -0
  66. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzlib.c +0 -0
  67. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzread.c +0 -0
  68. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzwrite.c +0 -0
  69. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.c +126 -44
  70. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.h +1 -1
  71. metadata +70 -65
  72. data/ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c +0 -216
  73. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c +0 -1138
  74. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h +0 -67
  75. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h +0 -192
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, 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
@@ -77,6 +77,7 @@ typedef enum {
77
77
  ZSTD_error_frameIndex_tooLarge = 100,
78
78
  ZSTD_error_seekableIO = 102,
79
79
  ZSTD_error_dstBuffer_wrong = 104,
80
+ ZSTD_error_srcBuffer_wrong = 105,
80
81
  ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
81
82
  } ZSTD_ErrorCode;
82
83
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2021, Przemyslaw Skibinski, 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
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2021, Przemyslaw Skibinski, 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
@@ -19,13 +19,13 @@
19
19
  #include <stdlib.h>
20
20
  #include <stdio.h> /* vsprintf */
21
21
  #include <stdarg.h> /* va_list, for z_gzprintf */
22
+ #include <string.h>
22
23
  #define NO_DUMMY_DECL
23
24
  #define ZLIB_CONST
24
25
  #include <zlib.h> /* without #define Z_PREFIX */
25
26
  #include "zstd_zlibwrapper.h"
26
- #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_isFrame, ZSTD_MAGICNUMBER */
27
+ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_isFrame, ZSTD_MAGICNUMBER, ZSTD_customMem */
27
28
  #include "zstd.h"
28
- #include "zstd_internal.h" /* ZSTD_malloc, ZSTD_free */
29
29
 
30
30
 
31
31
  /* === Constants === */
@@ -42,6 +42,45 @@
42
42
  #define FINISH_WITH_GZ_ERR(msg) { (void)msg; return Z_STREAM_ERROR; }
43
43
  #define FINISH_WITH_NULL_ERR(msg) { (void)msg; return NULL; }
44
44
 
45
+ /* === Utility === */
46
+
47
+ #define MIN(x,y) ((x) < (y) ? (x) : (y))
48
+
49
+ static unsigned ZWRAP_isLittleEndian(void)
50
+ {
51
+ const union { unsigned u; char c[4]; } one = { 1 }; /* don't use static : performance detrimental */
52
+ return one.c[0];
53
+ }
54
+
55
+ #ifndef __has_builtin
56
+ # define __has_builtin(x) 0
57
+ #endif
58
+
59
+ static unsigned ZWRAP_swap32(unsigned in)
60
+ {
61
+ #if defined(_MSC_VER) /* Visual Studio */
62
+ return _byteswap_ulong(in);
63
+ #elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
64
+ || (defined(__clang__) && __has_builtin(__builtin_bswap32))
65
+ return __builtin_bswap32(in);
66
+ #else
67
+ return ((in << 24) & 0xff000000 ) |
68
+ ((in << 8) & 0x00ff0000 ) |
69
+ ((in >> 8) & 0x0000ff00 ) |
70
+ ((in >> 24) & 0x000000ff );
71
+ #endif
72
+ }
73
+
74
+ static unsigned ZWRAP_readLE32(const void* ptr)
75
+ {
76
+ unsigned value;
77
+ memcpy(&value, ptr, sizeof(value));
78
+ if (ZWRAP_isLittleEndian())
79
+ return value;
80
+ else
81
+ return ZWRAP_swap32(value);
82
+ }
83
+
45
84
 
46
85
  /* === Wrapper === */
47
86
  static int g_ZWRAP_useZSTDcompression = ZWRAP_USE_ZSTD; /* 0 = don't use ZSTD */
@@ -64,8 +103,6 @@ const char * zstdVersion(void) { return ZSTD_VERSION_STRING; }
64
103
 
65
104
  ZEXTERN const char * ZEXPORT z_zlibVersion OF((void)) { return zlibVersion(); }
66
105
 
67
-
68
-
69
106
  static void* ZWRAP_allocFunction(void* opaque, size_t size)
70
107
  {
71
108
  z_streamp strm = (z_streamp) opaque;
@@ -81,6 +118,35 @@ static void ZWRAP_freeFunction(void* opaque, void* address)
81
118
  /* if (address) LOG_WRAPPERC("ZWRAP free %p \n", address); */
82
119
  }
83
120
 
121
+ static void* ZWRAP_customMalloc(size_t size, ZSTD_customMem customMem)
122
+ {
123
+ if (customMem.customAlloc)
124
+ return customMem.customAlloc(customMem.opaque, size);
125
+ return malloc(size);
126
+ }
127
+
128
+ static void* ZWRAP_customCalloc(size_t size, ZSTD_customMem customMem)
129
+ {
130
+ if (customMem.customAlloc) {
131
+ /* calloc implemented as malloc+memset;
132
+ * not as efficient as calloc, but next best guess for custom malloc */
133
+ void* const ptr = customMem.customAlloc(customMem.opaque, size);
134
+ memset(ptr, 0, size);
135
+ return ptr;
136
+ }
137
+ return calloc(1, size);
138
+ }
139
+
140
+ static void ZWRAP_customFree(void* ptr, ZSTD_customMem customMem)
141
+ {
142
+ if (ptr!=NULL) {
143
+ if (customMem.customFree)
144
+ customMem.customFree(customMem.opaque, ptr);
145
+ else
146
+ free(ptr);
147
+ }
148
+ }
149
+
84
150
 
85
151
 
86
152
  /* === Compression === */
@@ -107,7 +173,7 @@ static size_t ZWRAP_freeCCtx(ZWRAP_CCtx* zwc)
107
173
  {
108
174
  if (zwc==NULL) return 0; /* support free on NULL */
109
175
  ZSTD_freeCStream(zwc->zbc);
110
- ZSTD_free(zwc, zwc->customMem);
176
+ ZWRAP_customFree(zwc, zwc->customMem);
111
177
  return 0;
112
178
  }
113
179
 
@@ -115,20 +181,19 @@ static size_t ZWRAP_freeCCtx(ZWRAP_CCtx* zwc)
115
181
  static ZWRAP_CCtx* ZWRAP_createCCtx(z_streamp strm)
116
182
  {
117
183
  ZWRAP_CCtx* zwc;
184
+ ZSTD_customMem customMem = { NULL, NULL, NULL };
118
185
 
119
186
  if (strm->zalloc && strm->zfree) {
120
- zwc = (ZWRAP_CCtx*)strm->zalloc(strm->opaque, 1, sizeof(ZWRAP_CCtx));
121
- if (zwc==NULL) return NULL;
122
- memset(zwc, 0, sizeof(ZWRAP_CCtx));
123
- memcpy(&zwc->allocFunc, strm, sizeof(z_stream));
124
- { ZSTD_customMem ZWRAP_customMem = { ZWRAP_allocFunction, ZWRAP_freeFunction, NULL };
125
- ZWRAP_customMem.opaque = &zwc->allocFunc;
126
- zwc->customMem = ZWRAP_customMem;
127
- }
128
- } else {
129
- zwc = (ZWRAP_CCtx*)calloc(1, sizeof(*zwc));
130
- if (zwc==NULL) return NULL;
187
+ customMem.customAlloc = ZWRAP_allocFunction;
188
+ customMem.customFree = ZWRAP_freeFunction;
131
189
  }
190
+ customMem.opaque = strm;
191
+
192
+ zwc = (ZWRAP_CCtx*)ZWRAP_customCalloc(sizeof(ZWRAP_CCtx), customMem);
193
+ if (zwc == NULL) return NULL;
194
+ zwc->allocFunc = *strm;
195
+ customMem.opaque = &zwc->allocFunc;
196
+ zwc->customMem = customMem;
132
197
 
133
198
  return zwc;
134
199
  }
@@ -140,12 +205,21 @@ static int ZWRAP_initializeCStream(ZWRAP_CCtx* zwc, const void* dict, size_t dic
140
205
  if (zwc == NULL || zwc->zbc == NULL) return Z_STREAM_ERROR;
141
206
 
142
207
  if (!pledgedSrcSize) pledgedSrcSize = zwc->pledgedSrcSize;
143
- { ZSTD_parameters const params = ZSTD_getParams(zwc->compressionLevel, pledgedSrcSize, dictSize);
144
- size_t initErr;
208
+ { unsigned initErr = 0;
209
+ ZSTD_parameters const params = ZSTD_getParams(zwc->compressionLevel, pledgedSrcSize, dictSize);
210
+ ZSTD_CCtx_params* cctxParams = ZSTD_createCCtxParams();
211
+ if (!cctxParams) return Z_STREAM_ERROR;
145
212
  LOG_WRAPPERC("pledgedSrcSize=%d windowLog=%d chainLog=%d hashLog=%d searchLog=%d minMatch=%d strategy=%d\n",
146
213
  (int)pledgedSrcSize, params.cParams.windowLog, params.cParams.chainLog, params.cParams.hashLog, params.cParams.searchLog, params.cParams.minMatch, params.cParams.strategy);
147
- initErr = ZSTD_initCStream_advanced(zwc->zbc, dict, dictSize, params, pledgedSrcSize);
148
- if (ZSTD_isError(initErr)) return Z_STREAM_ERROR;
214
+
215
+ initErr |= ZSTD_isError(ZSTD_CCtx_reset(zwc->zbc, ZSTD_reset_session_only));
216
+ initErr |= ZSTD_isError(ZSTD_CCtxParams_init_advanced(cctxParams, params));
217
+ initErr |= ZSTD_isError(ZSTD_CCtx_setParametersUsingCCtxParams(zwc->zbc, cctxParams));
218
+ initErr |= ZSTD_isError(ZSTD_CCtx_setPledgedSrcSize(zwc->zbc, pledgedSrcSize));
219
+ initErr |= ZSTD_isError(ZSTD_CCtx_loadDictionary(zwc->zbc, dict, dictSize));
220
+
221
+ ZSTD_freeCCtxParams(cctxParams);
222
+ if (initErr) return Z_STREAM_ERROR;
149
223
  }
150
224
 
151
225
  return Z_OK;
@@ -181,6 +255,10 @@ int ZWRAP_setPledgedSrcSize(z_streamp strm, unsigned long long pledgedSrcSize)
181
255
  return Z_OK;
182
256
  }
183
257
 
258
+ static struct internal_state* convert_into_sis(void* ptr)
259
+ {
260
+ return (struct internal_state*) ptr;
261
+ }
184
262
 
185
263
  ZEXTERN int ZEXPORT z_deflateInit_ OF((z_streamp strm, int level,
186
264
  const char *version, int stream_size))
@@ -201,7 +279,7 @@ ZEXTERN int ZEXPORT z_deflateInit_ OF((z_streamp strm, int level,
201
279
  zwc->streamEnd = 0;
202
280
  zwc->totalInBytes = 0;
203
281
  zwc->compressionLevel = level;
204
- strm->state = (struct internal_state*) zwc; /* use state which in not used by user */
282
+ strm->state = convert_into_sis(zwc); /* use state which in not used by user */
205
283
  strm->total_in = 0;
206
284
  strm->total_out = 0;
207
285
  strm->adler = 0;
@@ -303,9 +381,15 @@ ZEXTERN int ZEXPORT z_deflate OF((z_streamp strm, int flush))
303
381
  } else {
304
382
  if (zwc->totalInBytes == 0) {
305
383
  if (zwc->comprState == ZWRAP_useReset) {
306
- size_t const resetErr = ZSTD_resetCStream(zwc->zbc, (flush == Z_FINISH) ? strm->avail_in : zwc->pledgedSrcSize);
384
+ size_t resetErr = ZSTD_CCtx_reset(zwc->zbc, ZSTD_reset_session_only);
385
+ if (ZSTD_isError(resetErr)) {
386
+ LOG_WRAPPERC("ERROR: ZSTD_CCtx_reset errorCode=%s\n",
387
+ ZSTD_getErrorName(resetErr));
388
+ return ZWRAPC_finishWithError(zwc, strm, 0);
389
+ }
390
+ resetErr = ZSTD_CCtx_setPledgedSrcSize(zwc->zbc, (flush == Z_FINISH) ? strm->avail_in : zwc->pledgedSrcSize);
307
391
  if (ZSTD_isError(resetErr)) {
308
- LOG_WRAPPERC("ERROR: ZSTD_resetCStream errorCode=%s\n",
392
+ LOG_WRAPPERC("ERROR: ZSTD_CCtx_setPledgedSrcSize errorCode=%s\n",
309
393
  ZSTD_getErrorName(resetErr));
310
394
  return ZWRAPC_finishWithError(zwc, strm, 0);
311
395
  }
@@ -457,21 +541,19 @@ static void ZWRAP_initDCtx(ZWRAP_DCtx* zwd)
457
541
  static ZWRAP_DCtx* ZWRAP_createDCtx(z_streamp strm)
458
542
  {
459
543
  ZWRAP_DCtx* zwd;
460
- MEM_STATIC_ASSERT(sizeof(zwd->headerBuf) >= ZSTD_HEADERSIZE); /* check static buffer size condition */
544
+ ZSTD_customMem customMem = { NULL, NULL, NULL };
461
545
 
462
546
  if (strm->zalloc && strm->zfree) {
463
- zwd = (ZWRAP_DCtx*)strm->zalloc(strm->opaque, 1, sizeof(ZWRAP_DCtx));
464
- if (zwd==NULL) return NULL;
465
- memset(zwd, 0, sizeof(ZWRAP_DCtx));
466
- zwd->allocFunc = *strm; /* just to copy zalloc, zfree & opaque */
467
- { ZSTD_customMem ZWRAP_customMem = { ZWRAP_allocFunction, ZWRAP_freeFunction, NULL };
468
- ZWRAP_customMem.opaque = &zwd->allocFunc;
469
- zwd->customMem = ZWRAP_customMem;
470
- }
471
- } else {
472
- zwd = (ZWRAP_DCtx*)calloc(1, sizeof(*zwd));
473
- if (zwd==NULL) return NULL;
547
+ customMem.customAlloc = ZWRAP_allocFunction;
548
+ customMem.customFree = ZWRAP_freeFunction;
474
549
  }
550
+ customMem.opaque = strm;
551
+
552
+ zwd = (ZWRAP_DCtx*)ZWRAP_customCalloc(sizeof(ZWRAP_DCtx), customMem);
553
+ if (zwd == NULL) return NULL;
554
+ zwd->allocFunc = *strm;
555
+ customMem.opaque = &zwd->allocFunc;
556
+ zwd->customMem = customMem;
475
557
 
476
558
  ZWRAP_initDCtx(zwd);
477
559
  return zwd;
@@ -481,8 +563,8 @@ static size_t ZWRAP_freeDCtx(ZWRAP_DCtx* zwd)
481
563
  {
482
564
  if (zwd==NULL) return 0; /* support free on null */
483
565
  ZSTD_freeDStream(zwd->zbd);
484
- ZSTD_free(zwd->version, zwd->customMem);
485
- ZSTD_free(zwd, zwd->customMem);
566
+ ZWRAP_customFree(zwd->version, zwd->customMem);
567
+ ZWRAP_customFree(zwd, zwd->customMem);
486
568
  return 0;
487
569
  }
488
570
 
@@ -524,13 +606,13 @@ ZEXTERN int ZEXPORT z_inflateInit_ OF((z_streamp strm,
524
606
  LOG_WRAPPERD("- inflateInit\n");
525
607
  if (zwd == NULL) return ZWRAPD_finishWithError(zwd, strm, 0);
526
608
 
527
- zwd->version = (char*)ZSTD_malloc(strlen(version)+1, zwd->customMem);
609
+ zwd->version = (char*)ZWRAP_customMalloc(strlen(version)+1, zwd->customMem);
528
610
  if (zwd->version == NULL) return ZWRAPD_finishWithError(zwd, strm, 0);
529
611
  strcpy(zwd->version, version);
530
612
 
531
613
  zwd->stream_size = stream_size;
532
614
  zwd->totalInBytes = 0;
533
- strm->state = (struct internal_state*) zwd;
615
+ strm->state = convert_into_sis(zwd);
534
616
  strm->total_in = 0;
535
617
  strm->total_out = 0;
536
618
  strm->reserved = ZWRAP_UNKNOWN_STREAM;
@@ -670,7 +752,7 @@ ZEXTERN int ZEXPORT z_inflate OF((z_streamp strm, int flush))
670
752
 
671
753
  if (zwd->totalInBytes < ZLIB_HEADERSIZE) {
672
754
  if (zwd->totalInBytes == 0 && strm->avail_in >= ZLIB_HEADERSIZE) {
673
- if (MEM_readLE32(strm->next_in) != ZSTD_MAGICNUMBER) {
755
+ if (ZWRAP_readLE32(strm->next_in) != ZSTD_MAGICNUMBER) {
674
756
  { int const initErr = (zwd->windowBits) ?
675
757
  inflateInit2_(strm, zwd->windowBits, zwd->version, zwd->stream_size) :
676
758
  inflateInit_(strm, zwd->version, zwd->stream_size);
@@ -698,7 +780,7 @@ ZEXTERN int ZEXPORT z_inflate OF((z_streamp strm, int flush))
698
780
  strm->avail_in -= srcSize;
699
781
  if (zwd->totalInBytes < ZLIB_HEADERSIZE) return Z_OK;
700
782
 
701
- if (MEM_readLE32(zwd->headerBuf) != ZSTD_MAGICNUMBER) {
783
+ if (ZWRAP_readLE32(zwd->headerBuf) != ZSTD_MAGICNUMBER) {
702
784
  z_stream strm2;
703
785
  strm2.next_in = strm->next_in;
704
786
  strm2.avail_in = strm->avail_in;
@@ -762,7 +844,7 @@ ZEXTERN int ZEXPORT z_inflate OF((z_streamp strm, int flush))
762
844
  goto error;
763
845
  }
764
846
  } else {
765
- size_t const resetErr = ZSTD_resetDStream(zwd->zbd);
847
+ size_t const resetErr = ZSTD_DCtx_reset(zwd->zbd, ZSTD_reset_session_only);
766
848
  if (ZSTD_isError(resetErr)) goto error;
767
849
  }
768
850
  } else {
@@ -782,7 +864,7 @@ ZEXTERN int ZEXPORT z_inflate OF((z_streamp strm, int flush))
782
864
  goto error;
783
865
  }
784
866
  } else {
785
- size_t const resetErr = ZSTD_resetDStream(zwd->zbd);
867
+ size_t const resetErr = ZSTD_DCtx_reset(zwd->zbd, ZSTD_reset_session_only);
786
868
  if (ZSTD_isError(resetErr)) goto error;
787
869
  }
788
870
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2021, Przemyslaw Skibinski, 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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zstdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg A. Khlybov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-25 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,7 @@ files:
100
100
  - ext/zstdlib/ruby/zlib-2.5/zstdlib.c
101
101
  - ext/zstdlib/ruby/zlib-2.6/zstdlib.c
102
102
  - ext/zstdlib/ruby/zlib-2.7/zstdlib.c
103
+ - ext/zstdlib/ruby/zlib-3.0/zstdlib.c
103
104
  - ext/zstdlib/zlib-1.2.11/adler32.c
104
105
  - ext/zstdlib/zlib-1.2.11/compress.c
105
106
  - ext/zstdlib/zlib-1.2.11/crc32.c
@@ -129,68 +130,72 @@ files:
129
130
  - ext/zstdlib/zlib.mk
130
131
  - ext/zstdlib/zlibwrapper.mk
131
132
  - ext/zstdlib/zlibwrapper/zlibwrapper.c
132
- - ext/zstdlib/zstd-1.4.5/lib/common/bitstream.h
133
- - ext/zstdlib/zstd-1.4.5/lib/common/compiler.h
134
- - ext/zstdlib/zstd-1.4.5/lib/common/cpu.h
135
- - ext/zstdlib/zstd-1.4.5/lib/common/debug.c
136
- - ext/zstdlib/zstd-1.4.5/lib/common/debug.h
137
- - ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c
138
- - ext/zstdlib/zstd-1.4.5/lib/common/error_private.c
139
- - ext/zstdlib/zstd-1.4.5/lib/common/error_private.h
140
- - ext/zstdlib/zstd-1.4.5/lib/common/fse.h
141
- - ext/zstdlib/zstd-1.4.5/lib/common/fse_decompress.c
142
- - ext/zstdlib/zstd-1.4.5/lib/common/huf.h
143
- - ext/zstdlib/zstd-1.4.5/lib/common/mem.h
144
- - ext/zstdlib/zstd-1.4.5/lib/common/pool.c
145
- - ext/zstdlib/zstd-1.4.5/lib/common/pool.h
146
- - ext/zstdlib/zstd-1.4.5/lib/common/threading.c
147
- - ext/zstdlib/zstd-1.4.5/lib/common/threading.h
148
- - ext/zstdlib/zstd-1.4.5/lib/common/xxhash.c
149
- - ext/zstdlib/zstd-1.4.5/lib/common/xxhash.h
150
- - ext/zstdlib/zstd-1.4.5/lib/common/zstd_common.c
151
- - ext/zstdlib/zstd-1.4.5/lib/common/zstd_errors.h
152
- - ext/zstdlib/zstd-1.4.5/lib/common/zstd_internal.h
153
- - ext/zstdlib/zstd-1.4.5/lib/compress/fse_compress.c
154
- - ext/zstdlib/zstd-1.4.5/lib/compress/hist.c
155
- - ext/zstdlib/zstd-1.4.5/lib/compress/hist.h
156
- - ext/zstdlib/zstd-1.4.5/lib/compress/huf_compress.c
157
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress.c
158
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_internal.h
159
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_literals.c
160
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_literals.h
161
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_sequences.c
162
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_sequences.h
163
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_superblock.c
164
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_superblock.h
165
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_cwksp.h
166
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_double_fast.c
167
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_double_fast.h
168
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_fast.c
169
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_fast.h
170
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c
171
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h
172
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_ldm.c
173
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_ldm.h
174
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_opt.c
175
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstd_opt.h
176
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.c
177
- - ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h
178
- - ext/zstdlib/zstd-1.4.5/lib/decompress/huf_decompress.c
179
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_ddict.c
180
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_ddict.h
181
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_decompress.c
182
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_decompress_block.c
183
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_decompress_block.h
184
- - ext/zstdlib/zstd-1.4.5/lib/decompress/zstd_decompress_internal.h
185
- - ext/zstdlib/zstd-1.4.5/lib/zstd.h
186
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzclose.c
187
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzcompatibility.h
188
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzguts.h
189
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzlib.c
190
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzread.c
191
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/gzwrite.c
192
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/zstd_zlibwrapper.c
193
- - ext/zstdlib/zstd-1.4.5/zlibWrapper/zstd_zlibwrapper.h
133
+ - ext/zstdlib/zstd-1.5.0/lib/common/bitstream.h
134
+ - ext/zstdlib/zstd-1.5.0/lib/common/compiler.h
135
+ - ext/zstdlib/zstd-1.5.0/lib/common/cpu.h
136
+ - ext/zstdlib/zstd-1.5.0/lib/common/debug.c
137
+ - ext/zstdlib/zstd-1.5.0/lib/common/debug.h
138
+ - ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c
139
+ - ext/zstdlib/zstd-1.5.0/lib/common/error_private.c
140
+ - ext/zstdlib/zstd-1.5.0/lib/common/error_private.h
141
+ - ext/zstdlib/zstd-1.5.0/lib/common/fse.h
142
+ - ext/zstdlib/zstd-1.5.0/lib/common/fse_decompress.c
143
+ - ext/zstdlib/zstd-1.5.0/lib/common/huf.h
144
+ - ext/zstdlib/zstd-1.5.0/lib/common/mem.h
145
+ - ext/zstdlib/zstd-1.5.0/lib/common/pool.c
146
+ - ext/zstdlib/zstd-1.5.0/lib/common/pool.h
147
+ - ext/zstdlib/zstd-1.5.0/lib/common/threading.c
148
+ - ext/zstdlib/zstd-1.5.0/lib/common/threading.h
149
+ - ext/zstdlib/zstd-1.5.0/lib/common/xxhash.c
150
+ - ext/zstdlib/zstd-1.5.0/lib/common/xxhash.h
151
+ - ext/zstdlib/zstd-1.5.0/lib/common/zstd_common.c
152
+ - ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h
153
+ - ext/zstdlib/zstd-1.5.0/lib/common/zstd_internal.h
154
+ - ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h
155
+ - ext/zstdlib/zstd-1.5.0/lib/compress/fse_compress.c
156
+ - ext/zstdlib/zstd-1.5.0/lib/compress/hist.c
157
+ - ext/zstdlib/zstd-1.5.0/lib/compress/hist.h
158
+ - ext/zstdlib/zstd-1.5.0/lib/compress/huf_compress.c
159
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress.c
160
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_internal.h
161
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_literals.c
162
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_literals.h
163
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_sequences.c
164
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_sequences.h
165
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.c
166
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.h
167
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_cwksp.h
168
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_double_fast.c
169
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_double_fast.h
170
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_fast.c
171
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_fast.h
172
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c
173
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h
174
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm.c
175
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm.h
176
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h
177
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_opt.c
178
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstd_opt.h
179
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.c
180
+ - ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h
181
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/huf_decompress.c
182
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_ddict.c
183
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_ddict.h
184
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_decompress.c
185
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_decompress_block.c
186
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_decompress_block.h
187
+ - ext/zstdlib/zstd-1.5.0/lib/decompress/zstd_decompress_internal.h
188
+ - ext/zstdlib/zstd-1.5.0/lib/zdict.h
189
+ - ext/zstdlib/zstd-1.5.0/lib/zstd.h
190
+ - ext/zstdlib/zstd-1.5.0/lib/zstd_errors.h
191
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzclose.c
192
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzcompatibility.h
193
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzguts.h
194
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzlib.c
195
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzread.c
196
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/gzwrite.c
197
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/zstd_zlibwrapper.c
198
+ - ext/zstdlib/zstd-1.5.0/zlibWrapper/zstd_zlibwrapper.h
194
199
  - ext/zstdlib/zstd.mk
195
200
  - lib/zstdlib.rb
196
201
  - test/zstdlib_test.rb
@@ -213,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
218
  - !ruby/object:Gem::Version
214
219
  version: '0'
215
220
  requirements: []
216
- rubygems_version: 3.1.2
221
+ rubygems_version: 3.2.15
217
222
  signing_key:
218
223
  specification_version: 4
219
224
  summary: Ruby interface for the Zstd data compression library