zstd-ruby 1.4.4.0 → 1.4.5.0

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/README.md +1 -1
  3. data/ext/zstdruby/libzstd/Makefile +123 -58
  4. data/ext/zstdruby/libzstd/README.md +34 -14
  5. data/ext/zstdruby/libzstd/common/bitstream.h +31 -37
  6. data/ext/zstdruby/libzstd/common/compiler.h +19 -3
  7. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  8. data/ext/zstdruby/libzstd/common/debug.c +11 -31
  9. data/ext/zstdruby/libzstd/common/debug.h +11 -31
  10. data/ext/zstdruby/libzstd/common/entropy_common.c +13 -33
  11. data/ext/zstdruby/libzstd/common/error_private.c +2 -1
  12. data/ext/zstdruby/libzstd/common/error_private.h +6 -2
  13. data/ext/zstdruby/libzstd/common/fse.h +11 -31
  14. data/ext/zstdruby/libzstd/common/fse_decompress.c +12 -37
  15. data/ext/zstdruby/libzstd/common/huf.h +15 -33
  16. data/ext/zstdruby/libzstd/common/mem.h +1 -1
  17. data/ext/zstdruby/libzstd/common/pool.c +1 -1
  18. data/ext/zstdruby/libzstd/common/pool.h +2 -2
  19. data/ext/zstdruby/libzstd/common/threading.c +4 -3
  20. data/ext/zstdruby/libzstd/common/threading.h +4 -3
  21. data/ext/zstdruby/libzstd/common/xxhash.c +15 -33
  22. data/ext/zstdruby/libzstd/common/xxhash.h +11 -31
  23. data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
  24. data/ext/zstdruby/libzstd/common/zstd_errors.h +2 -1
  25. data/ext/zstdruby/libzstd/common/zstd_internal.h +112 -15
  26. data/ext/zstdruby/libzstd/compress/fse_compress.c +17 -40
  27. data/ext/zstdruby/libzstd/compress/hist.c +15 -35
  28. data/ext/zstdruby/libzstd/compress/hist.h +12 -32
  29. data/ext/zstdruby/libzstd/compress/huf_compress.c +92 -92
  30. data/ext/zstdruby/libzstd/compress/zstd_compress.c +450 -275
  31. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +136 -14
  32. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +10 -6
  33. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +1 -1
  34. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +24 -20
  35. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +10 -3
  36. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +845 -0
  37. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +32 -0
  38. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +3 -13
  39. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +11 -8
  40. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +2 -2
  41. data/ext/zstdruby/libzstd/compress/zstd_fast.c +36 -24
  42. data/ext/zstdruby/libzstd/compress/zstd_fast.h +2 -2
  43. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +34 -11
  44. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +1 -1
  45. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +27 -5
  46. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +7 -2
  47. data/ext/zstdruby/libzstd/compress/zstd_opt.c +38 -84
  48. data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
  49. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +48 -21
  50. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +2 -2
  51. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +76 -62
  52. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +12 -8
  53. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
  54. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +264 -148
  55. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +312 -203
  56. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +3 -3
  57. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +18 -4
  58. data/ext/zstdruby/libzstd/deprecated/zbuff.h +3 -3
  59. data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +2 -2
  60. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -1
  61. data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
  62. data/ext/zstdruby/libzstd/dictBuilder/cover.c +5 -5
  63. data/ext/zstdruby/libzstd/dictBuilder/cover.h +14 -4
  64. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +14 -4
  65. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +33 -9
  66. data/ext/zstdruby/libzstd/dictBuilder/zdict.h +51 -28
  67. data/ext/zstdruby/libzstd/dll/example/Makefile +2 -1
  68. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +4 -4
  69. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +18 -12
  70. data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
  71. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +10 -6
  72. data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
  73. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +10 -6
  74. data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
  75. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +13 -7
  76. data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
  77. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +17 -13
  78. data/ext/zstdruby/libzstd/legacy/zstd_v05.h +2 -2
  79. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +17 -13
  80. data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
  81. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +22 -14
  82. data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
  83. data/ext/zstdruby/libzstd/libzstd.pc.in +2 -2
  84. data/ext/zstdruby/libzstd/zstd.h +62 -21
  85. data/lib/zstd-ruby/version.rb +1 -1
  86. metadata +7 -5
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -11,7 +11,7 @@
11
11
 
12
12
  #include <stddef.h> /* size_t, ptrdiff_t */
13
13
  #include "zstd_v02.h"
14
- #include "error_private.h"
14
+ #include "../common/error_private.h"
15
15
 
16
16
 
17
17
  /******************************************
@@ -189,7 +189,7 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
189
189
  memcpy(memPtr, &value, sizeof(value));
190
190
  }
191
191
 
192
- #endif // MEM_FORCE_MEMORY_ACCESS
192
+ #endif /* MEM_FORCE_MEMORY_ACCESS */
193
193
 
194
194
 
195
195
  MEM_STATIC U16 MEM_readLE16(const void* memPtr)
@@ -2836,7 +2836,9 @@ static size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockPropertie
2836
2836
  static size_t ZSTD_copyUncompressedBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
2837
2837
  {
2838
2838
  if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
2839
- memcpy(dst, src, srcSize);
2839
+ if (srcSize > 0) {
2840
+ memcpy(dst, src, srcSize);
2841
+ }
2840
2842
  return srcSize;
2841
2843
  }
2842
2844
 
@@ -3229,8 +3231,10 @@ static size_t ZSTD_decompressSequences(
3229
3231
  size_t lastLLSize = litEnd - litPtr;
3230
3232
  if (litPtr > litEnd) return ERROR(corruption_detected);
3231
3233
  if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
3232
- if (op != litPtr) memmove(op, litPtr, lastLLSize);
3233
- op += lastLLSize;
3234
+ if (lastLLSize > 0) {
3235
+ if (op != litPtr) memmove(op, litPtr, lastLLSize);
3236
+ op += lastLLSize;
3237
+ }
3234
3238
  }
3235
3239
  }
3236
3240
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -11,7 +11,7 @@
11
11
 
12
12
  #include <stddef.h> /* size_t, ptrdiff_t */
13
13
  #include "zstd_v03.h"
14
- #include "error_private.h"
14
+ #include "../common/error_private.h"
15
15
 
16
16
 
17
17
  /******************************************
@@ -191,7 +191,7 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
191
191
  }
192
192
 
193
193
 
194
- #endif // MEM_FORCE_MEMORY_ACCESS
194
+ #endif /* MEM_FORCE_MEMORY_ACCESS */
195
195
 
196
196
 
197
197
  MEM_STATIC U16 MEM_readLE16(const void* memPtr)
@@ -2477,7 +2477,9 @@ static size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockPropertie
2477
2477
  static size_t ZSTD_copyUncompressedBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
2478
2478
  {
2479
2479
  if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
2480
- memcpy(dst, src, srcSize);
2480
+ if (srcSize > 0) {
2481
+ memcpy(dst, src, srcSize);
2482
+ }
2481
2483
  return srcSize;
2482
2484
  }
2483
2485
 
@@ -2870,8 +2872,10 @@ static size_t ZSTD_decompressSequences(
2870
2872
  size_t lastLLSize = litEnd - litPtr;
2871
2873
  if (litPtr > litEnd) return ERROR(corruption_detected);
2872
2874
  if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
2873
- if (op != litPtr) memmove(op, litPtr, lastLLSize);
2874
- op += lastLLSize;
2875
+ if (lastLLSize > 0) {
2876
+ if (op != litPtr) memmove(op, litPtr, lastLLSize);
2877
+ op += lastLLSize;
2878
+ }
2875
2879
  }
2876
2880
  }
2877
2881
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -16,7 +16,7 @@
16
16
  #include <string.h> /* memcpy */
17
17
 
18
18
  #include "zstd_v04.h"
19
- #include "error_private.h"
19
+ #include "../common/error_private.h"
20
20
 
21
21
 
22
22
  /* ******************************************************************
@@ -161,7 +161,7 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
161
161
  memcpy(memPtr, &value, sizeof(value));
162
162
  }
163
163
 
164
- #endif // MEM_FORCE_MEMORY_ACCESS
164
+ #endif /* MEM_FORCE_MEMORY_ACCESS */
165
165
 
166
166
 
167
167
  MEM_STATIC U16 MEM_readLE16(const void* memPtr)
@@ -2603,7 +2603,9 @@ static size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockPropertie
2603
2603
  static size_t ZSTD_copyRawBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
2604
2604
  {
2605
2605
  if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
2606
- memcpy(dst, src, srcSize);
2606
+ if (srcSize > 0) {
2607
+ memcpy(dst, src, srcSize);
2608
+ }
2607
2609
  return srcSize;
2608
2610
  }
2609
2611
 
@@ -3008,8 +3010,10 @@ static size_t ZSTD_decompressSequences(
3008
3010
  size_t lastLLSize = litEnd - litPtr;
3009
3011
  if (litPtr > litEnd) return ERROR(corruption_detected);
3010
3012
  if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
3011
- if (op != litPtr) memcpy(op, litPtr, lastLLSize);
3012
- op += lastLLSize;
3013
+ if (lastLLSize > 0) {
3014
+ if (op != litPtr) memcpy(op, litPtr, lastLLSize);
3015
+ op += lastLLSize;
3016
+ }
3013
3017
  }
3014
3018
  }
3015
3019
 
@@ -3407,7 +3411,9 @@ static size_t ZBUFF_decompressWithDictionary(ZBUFF_DCtx* zbc, const void* src, s
3407
3411
  static size_t ZBUFF_limitCopy(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
3408
3412
  {
3409
3413
  size_t length = MIN(maxDstSize, srcSize);
3410
- memcpy(dst, src, length);
3414
+ if (length > 0) {
3415
+ memcpy(dst, src, length);
3416
+ }
3411
3417
  return length;
3412
3418
  }
3413
3419
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -11,7 +11,7 @@
11
11
 
12
12
  /*- Dependencies -*/
13
13
  #include "zstd_v05.h"
14
- #include "error_private.h"
14
+ #include "../common/error_private.h"
15
15
 
16
16
 
17
17
  /* ******************************************************************
@@ -1804,7 +1804,7 @@ static size_t HUFv05_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
1804
1804
 
1805
1805
  if (!srcSize) return ERROR(srcSize_wrong);
1806
1806
  iSize = ip[0];
1807
- //memset(huffWeight, 0, hwSize); /* is not necessary, even though some analyzer complain ... */
1807
+ /* memset(huffWeight, 0, hwSize); */ /* is not necessary, even though some analyzer complain ... */
1808
1808
 
1809
1809
  if (iSize >= 128) { /* special header */
1810
1810
  if (iSize >= (242)) { /* RLE */
@@ -1879,7 +1879,7 @@ size_t HUFv05_readDTableX2 (U16* DTable, const void* src, size_t srcSize)
1879
1879
  HUFv05_DEltX2* const dt = (HUFv05_DEltX2*)dtPtr;
1880
1880
 
1881
1881
  HUFv05_STATIC_ASSERT(sizeof(HUFv05_DEltX2) == sizeof(U16)); /* if compilation fails here, assertion is false */
1882
- //memset(huffWeight, 0, sizeof(huffWeight)); /* is not necessary, even though some analyzer complain ... */
1882
+ /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
1883
1883
 
1884
1884
  iSize = HUFv05_readStats(huffWeight, HUFv05_MAX_SYMBOL_VALUE + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
1885
1885
  if (HUFv05_isError(iSize)) return iSize;
@@ -2210,7 +2210,7 @@ size_t HUFv05_readDTableX4 (unsigned* DTable, const void* src, size_t srcSize)
2210
2210
 
2211
2211
  HUFv05_STATIC_ASSERT(sizeof(HUFv05_DEltX4) == sizeof(unsigned)); /* if compilation fails here, assertion is false */
2212
2212
  if (memLog > HUFv05_ABSOLUTEMAX_TABLELOG) return ERROR(tableLog_tooLarge);
2213
- //memset(weightList, 0, sizeof(weightList)); /* is not necessary, even though some analyzer complain ... */
2213
+ /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
2214
2214
 
2215
2215
  iSize = HUFv05_readStats(weightList, HUFv05_MAX_SYMBOL_VALUE + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
2216
2216
  if (HUFv05_isError(iSize)) return iSize;
@@ -2539,9 +2539,9 @@ size_t HUFv05_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
2539
2539
 
2540
2540
  return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
2541
2541
 
2542
- //return HUFv05_decompress4X2(dst, dstSize, cSrc, cSrcSize); /* multi-streams single-symbol decoding */
2543
- //return HUFv05_decompress4X4(dst, dstSize, cSrc, cSrcSize); /* multi-streams double-symbols decoding */
2544
- //return HUFv05_decompress4X6(dst, dstSize, cSrc, cSrcSize); /* multi-streams quad-symbols decoding */
2542
+ /* return HUFv05_decompress4X2(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams single-symbol decoding */
2543
+ /* return HUFv05_decompress4X4(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams double-symbols decoding */
2544
+ /* return HUFv05_decompress4X6(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams quad-symbols decoding */
2545
2545
  }
2546
2546
  /*
2547
2547
  zstd - standard compression library
@@ -3362,8 +3362,10 @@ static size_t ZSTDv05_decompressSequences(
3362
3362
  size_t lastLLSize = litEnd - litPtr;
3363
3363
  if (litPtr > litEnd) return ERROR(corruption_detected); /* too many literals already used */
3364
3364
  if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
3365
- memcpy(op, litPtr, lastLLSize);
3366
- op += lastLLSize;
3365
+ if (lastLLSize > 0) {
3366
+ memcpy(op, litPtr, lastLLSize);
3367
+ op += lastLLSize;
3368
+ }
3367
3369
  }
3368
3370
 
3369
3371
  return op-ostart;
@@ -3791,7 +3793,9 @@ static size_t ZBUFFv05_blockHeaderSize = 3;
3791
3793
  static size_t ZBUFFv05_limitCopy(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
3792
3794
  {
3793
3795
  size_t length = MIN(maxDstSize, srcSize);
3794
- memcpy(dst, src, length);
3796
+ if (length > 0) {
3797
+ memcpy(dst, src, length);
3798
+ }
3795
3799
  return length;
3796
3800
  }
3797
3801
 
@@ -3928,7 +3932,7 @@ size_t ZBUFFv05_decompressContinue(ZBUFFv05_DCtx* zbc, void* dst, size_t* maxDst
3928
3932
  *maxDstSizePtr = 0;
3929
3933
  return headerSize - zbc->hPos;
3930
3934
  }
3931
- // zbc->stage = ZBUFFv05ds_decodeHeader; break; /* useless : stage follows */
3935
+ /* zbc->stage = ZBUFFv05ds_decodeHeader; break; */ /* useless : stage follows */
3932
3936
  }
3933
3937
  /* fall-through */
3934
3938
  case ZBUFFv05ds_decodeHeader:
@@ -4001,7 +4005,7 @@ size_t ZBUFFv05_decompressContinue(ZBUFFv05_DCtx* zbc, void* dst, size_t* maxDst
4001
4005
  if (!decodedSize) { zbc->stage = ZBUFFv05ds_read; break; } /* this was just a header */
4002
4006
  zbc->outEnd = zbc->outStart + decodedSize;
4003
4007
  zbc->stage = ZBUFFv05ds_flush;
4004
- // break; /* ZBUFFv05ds_flush follows */
4008
+ /* break; */ /* ZBUFFv05ds_flush follows */
4005
4009
  }
4006
4010
  }
4007
4011
  /* fall-through */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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,7 +19,7 @@ extern "C" {
19
19
  * Dependencies
20
20
  ***************************************/
21
21
  #include <stddef.h> /* size_t */
22
- #include "mem.h" /* U64, U32 */
22
+ #include "../common/mem.h" /* U64, U32 */
23
23
 
24
24
 
25
25
  /* *************************************
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -14,7 +14,7 @@
14
14
  #include <stddef.h> /* size_t, ptrdiff_t */
15
15
  #include <string.h> /* memcpy */
16
16
  #include <stdlib.h> /* malloc, free, qsort */
17
- #include "error_private.h"
17
+ #include "../common/error_private.h"
18
18
 
19
19
 
20
20
 
@@ -1862,7 +1862,7 @@ MEM_STATIC size_t HUFv06_readStats(BYTE* huffWeight, size_t hwSize, U32* rankSta
1862
1862
 
1863
1863
  if (!srcSize) return ERROR(srcSize_wrong);
1864
1864
  iSize = ip[0];
1865
- //memset(huffWeight, 0, hwSize); /* is not necessary, even though some analyzer complain ... */
1865
+ /* memset(huffWeight, 0, hwSize); */ /* is not necessary, even though some analyzer complain ... */
1866
1866
 
1867
1867
  if (iSize >= 128) { /* special header */
1868
1868
  if (iSize >= (242)) { /* RLE */
@@ -2014,7 +2014,7 @@ size_t HUFv06_readDTableX2 (U16* DTable, const void* src, size_t srcSize)
2014
2014
  HUFv06_DEltX2* const dt = (HUFv06_DEltX2*)dtPtr;
2015
2015
 
2016
2016
  HUFv06_STATIC_ASSERT(sizeof(HUFv06_DEltX2) == sizeof(U16)); /* if compilation fails here, assertion is false */
2017
- //memset(huffWeight, 0, sizeof(huffWeight)); /* is not necessary, even though some analyzer complain ... */
2017
+ /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
2018
2018
 
2019
2019
  iSize = HUFv06_readStats(huffWeight, HUFv06_MAX_SYMBOL_VALUE + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
2020
2020
  if (HUFv06_isError(iSize)) return iSize;
@@ -2340,7 +2340,7 @@ size_t HUFv06_readDTableX4 (U32* DTable, const void* src, size_t srcSize)
2340
2340
 
2341
2341
  HUFv06_STATIC_ASSERT(sizeof(HUFv06_DEltX4) == sizeof(U32)); /* if compilation fails here, assertion is false */
2342
2342
  if (memLog > HUFv06_ABSOLUTEMAX_TABLELOG) return ERROR(tableLog_tooLarge);
2343
- //memset(weightList, 0, sizeof(weightList)); /* is not necessary, even though some analyzer complain ... */
2343
+ /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
2344
2344
 
2345
2345
  iSize = HUFv06_readStats(weightList, HUFv06_MAX_SYMBOL_VALUE + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
2346
2346
  if (HUFv06_isError(iSize)) return iSize;
@@ -2664,13 +2664,13 @@ size_t HUFv06_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
2664
2664
 
2665
2665
  { U32 algoNb = 0;
2666
2666
  if (Dtime[1] < Dtime[0]) algoNb = 1;
2667
- // if (Dtime[2] < Dtime[algoNb]) algoNb = 2; /* current speed of HUFv06_decompress4X6 is not good */
2667
+ /* if (Dtime[2] < Dtime[algoNb]) algoNb = 2; */ /* current speed of HUFv06_decompress4X6 is not good */
2668
2668
  return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
2669
2669
  }
2670
2670
 
2671
- //return HUFv06_decompress4X2(dst, dstSize, cSrc, cSrcSize); /* multi-streams single-symbol decoding */
2672
- //return HUFv06_decompress4X4(dst, dstSize, cSrc, cSrcSize); /* multi-streams double-symbols decoding */
2673
- //return HUFv06_decompress4X6(dst, dstSize, cSrc, cSrcSize); /* multi-streams quad-symbols decoding */
2671
+ /* return HUFv06_decompress4X2(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams single-symbol decoding */
2672
+ /* return HUFv06_decompress4X4(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams double-symbols decoding */
2673
+ /* return HUFv06_decompress4X6(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams quad-symbols decoding */
2674
2674
  }
2675
2675
  /*
2676
2676
  Common functions of Zstd compression library
@@ -3501,8 +3501,10 @@ static size_t ZSTDv06_decompressSequences(
3501
3501
  { size_t const lastLLSize = litEnd - litPtr;
3502
3502
  if (litPtr > litEnd) return ERROR(corruption_detected); /* too many literals already used */
3503
3503
  if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
3504
- memcpy(op, litPtr, lastLLSize);
3505
- op += lastLLSize;
3504
+ if (lastLLSize > 0) {
3505
+ memcpy(op, litPtr, lastLLSize);
3506
+ op += lastLLSize;
3507
+ }
3506
3508
  }
3507
3509
 
3508
3510
  return op-ostart;
@@ -4000,7 +4002,9 @@ size_t ZBUFFv06_decompressInit(ZBUFFv06_DCtx* zbd)
4000
4002
  MEM_STATIC size_t ZBUFFv06_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
4001
4003
  {
4002
4004
  size_t length = MIN(dstCapacity, srcSize);
4003
- memcpy(dst, src, length);
4005
+ if (length > 0) {
4006
+ memcpy(dst, src, length);
4007
+ }
4004
4008
  return length;
4005
4009
  }
4006
4010
 
@@ -4109,7 +4113,7 @@ size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* zbd,
4109
4113
  if (!decodedSize) { zbd->stage = ZBUFFds_read; break; } /* this was just a header */
4110
4114
  zbd->outEnd = zbd->outStart + decodedSize;
4111
4115
  zbd->stage = ZBUFFds_flush;
4112
- // break; /* ZBUFFds_flush follows */
4116
+ /* break; */ /* ZBUFFds_flush follows */
4113
4117
  }
4114
4118
  }
4115
4119
  /* fall-through */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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-present, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 2016-2020, 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
@@ -17,14 +17,14 @@
17
17
  #ifndef XXH_STATIC_LINKING_ONLY
18
18
  # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
19
19
  #endif
20
- #include "xxhash.h" /* XXH64_* */
20
+ #include "../common/xxhash.h" /* XXH64_* */
21
21
  #include "zstd_v07.h"
22
22
 
23
23
  #define FSEv07_STATIC_LINKING_ONLY /* FSEv07_MIN_TABLELOG */
24
24
  #define HUFv07_STATIC_LINKING_ONLY /* HUFv07_TABLELOG_ABSOLUTEMAX */
25
25
  #define ZSTDv07_STATIC_LINKING_ONLY
26
26
 
27
- #include "error_private.h"
27
+ #include "../common/error_private.h"
28
28
 
29
29
 
30
30
  #ifdef ZSTDv07_STATIC_LINKING_ONLY
@@ -1314,7 +1314,7 @@ size_t HUFv07_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
1314
1314
 
1315
1315
  if (!srcSize) return ERROR(srcSize_wrong);
1316
1316
  iSize = ip[0];
1317
- //memset(huffWeight, 0, hwSize); /* is not necessary, even though some analyzer complain ... */
1317
+ /* memset(huffWeight, 0, hwSize); */ /* is not necessary, even though some analyzer complain ... */
1318
1318
 
1319
1319
  if (iSize >= 128) { /* special header */
1320
1320
  if (iSize >= (242)) { /* RLE */
@@ -1784,7 +1784,7 @@ size_t HUFv07_readDTableX2 (HUFv07_DTable* DTable, const void* src, size_t srcSi
1784
1784
  HUFv07_DEltX2* const dt = (HUFv07_DEltX2*)dtPtr;
1785
1785
 
1786
1786
  HUFv07_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUFv07_DTable));
1787
- //memset(huffWeight, 0, sizeof(huffWeight)); /* is not necessary, even though some analyzer complain ... */
1787
+ /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
1788
1788
 
1789
1789
  iSize = HUFv07_readStats(huffWeight, HUFv07_SYMBOLVALUE_MAX + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
1790
1790
  if (HUFv07_isError(iSize)) return iSize;
@@ -2148,7 +2148,7 @@ size_t HUFv07_readDTableX4 (HUFv07_DTable* DTable, const void* src, size_t srcSi
2148
2148
 
2149
2149
  HUFv07_STATIC_ASSERT(sizeof(HUFv07_DEltX4) == sizeof(HUFv07_DTable)); /* if compilation fails here, assertion is false */
2150
2150
  if (maxTableLog > HUFv07_TABLELOG_ABSOLUTEMAX) return ERROR(tableLog_tooLarge);
2151
- //memset(weightList, 0, sizeof(weightList)); /* is not necessary, even though some analyzer complain ... */
2151
+ /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
2152
2152
 
2153
2153
  iSize = HUFv07_readStats(weightList, HUFv07_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
2154
2154
  if (HUFv07_isError(iSize)) return iSize;
@@ -2530,8 +2530,8 @@ size_t HUFv07_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
2530
2530
  return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
2531
2531
  }
2532
2532
 
2533
- //return HUFv07_decompress4X2(dst, dstSize, cSrc, cSrcSize); /* multi-streams single-symbol decoding */
2534
- //return HUFv07_decompress4X4(dst, dstSize, cSrc, cSrcSize); /* multi-streams double-symbols decoding */
2533
+ /* return HUFv07_decompress4X2(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams single-symbol decoding */
2534
+ /* return HUFv07_decompress4X4(dst, dstSize, cSrc, cSrcSize); */ /* multi-streams double-symbols decoding */
2535
2535
  }
2536
2536
 
2537
2537
  size_t HUFv07_decompress4X_DCtx (HUFv07_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
@@ -3272,7 +3272,9 @@ static size_t ZSTDv07_getcBlockSize(const void* src, size_t srcSize, blockProper
3272
3272
  static size_t ZSTDv07_copyRawBlock(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
3273
3273
  {
3274
3274
  if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall);
3275
- memcpy(dst, src, srcSize);
3275
+ if (srcSize > 0) {
3276
+ memcpy(dst, src, srcSize);
3277
+ }
3276
3278
  return srcSize;
3277
3279
  }
3278
3280
 
@@ -3712,10 +3714,12 @@ static size_t ZSTDv07_decompressSequences(
3712
3714
 
3713
3715
  /* last literal segment */
3714
3716
  { size_t const lastLLSize = litEnd - litPtr;
3715
- //if (litPtr > litEnd) return ERROR(corruption_detected); /* too many literals already used */
3717
+ /* if (litPtr > litEnd) return ERROR(corruption_detected); */ /* too many literals already used */
3716
3718
  if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall);
3717
- memcpy(op, litPtr, lastLLSize);
3718
- op += lastLLSize;
3719
+ if (lastLLSize > 0) {
3720
+ memcpy(op, litPtr, lastLLSize);
3721
+ op += lastLLSize;
3722
+ }
3719
3723
  }
3720
3724
 
3721
3725
  return op-ostart;
@@ -3776,7 +3780,9 @@ ZSTDLIBv07_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockS
3776
3780
  static size_t ZSTDv07_generateNxBytes(void* dst, size_t dstCapacity, BYTE byte, size_t length)
3777
3781
  {
3778
3782
  if (length > dstCapacity) return ERROR(dstSize_tooSmall);
3779
- memset(dst, byte, length);
3783
+ if (length > 0) {
3784
+ memset(dst, byte, length);
3785
+ }
3780
3786
  return length;
3781
3787
  }
3782
3788
 
@@ -4378,7 +4384,9 @@ size_t ZBUFFv07_decompressInit(ZBUFFv07_DCtx* zbd)
4378
4384
  MEM_STATIC size_t ZBUFFv07_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
4379
4385
  {
4380
4386
  size_t const length = MIN(dstCapacity, srcSize);
4381
- memcpy(dst, src, length);
4387
+ if (length > 0) {
4388
+ memcpy(dst, src, length);
4389
+ }
4382
4390
  return length;
4383
4391
  }
4384
4392