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,149 @@
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
+ #ifndef ZSTDv05_H
11
+ #define ZSTDv05_H
12
+
13
+ #if defined (__cplusplus)
14
+ extern "C" {
15
+ #endif
16
+
17
+ /*-*************************************
18
+ * Dependencies
19
+ ***************************************/
20
+ #include <stddef.h> /* size_t */
21
+ #include "mem.h" /* U64, U32 */
22
+
23
+
24
+ /* *************************************
25
+ * Simple functions
26
+ ***************************************/
27
+ /*! ZSTDv05_decompress() :
28
+ `compressedSize` : is the _exact_ size of the compressed blob, otherwise decompression will fail.
29
+ `dstCapacity` must be large enough, equal or larger than originalSize.
30
+ @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
31
+ or an errorCode if it fails (which can be tested using ZSTDv05_isError()) */
32
+ size_t ZSTDv05_decompress( void* dst, size_t dstCapacity,
33
+ const void* src, size_t compressedSize);
34
+
35
+
36
+ /* *************************************
37
+ * Helper functions
38
+ ***************************************/
39
+ /* Error Management */
40
+ unsigned ZSTDv05_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
41
+ const char* ZSTDv05_getErrorName(size_t code); /*!< provides readable string for an error code */
42
+
43
+
44
+ /* *************************************
45
+ * Explicit memory management
46
+ ***************************************/
47
+ /** Decompression context */
48
+ typedef struct ZSTDv05_DCtx_s ZSTDv05_DCtx;
49
+ ZSTDv05_DCtx* ZSTDv05_createDCtx(void);
50
+ size_t ZSTDv05_freeDCtx(ZSTDv05_DCtx* dctx); /*!< @return : errorCode */
51
+
52
+ /** ZSTDv05_decompressDCtx() :
53
+ * Same as ZSTDv05_decompress(), but requires an already allocated ZSTDv05_DCtx (see ZSTDv05_createDCtx()) */
54
+ size_t ZSTDv05_decompressDCtx(ZSTDv05_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
55
+
56
+
57
+ /*-***********************
58
+ * Simple Dictionary API
59
+ *************************/
60
+ /*! ZSTDv05_decompress_usingDict() :
61
+ * Decompression using a pre-defined Dictionary content (see dictBuilder).
62
+ * Dictionary must be identical to the one used during compression, otherwise regenerated data will be corrupted.
63
+ * Note : dict can be NULL, in which case, it's equivalent to ZSTDv05_decompressDCtx() */
64
+ size_t ZSTDv05_decompress_usingDict(ZSTDv05_DCtx* dctx,
65
+ void* dst, size_t dstCapacity,
66
+ const void* src, size_t srcSize,
67
+ const void* dict,size_t dictSize);
68
+
69
+ /*-************************
70
+ * Advanced Streaming API
71
+ ***************************/
72
+ typedef enum { ZSTDv05_fast, ZSTDv05_greedy, ZSTDv05_lazy, ZSTDv05_lazy2, ZSTDv05_btlazy2, ZSTDv05_opt, ZSTDv05_btopt } ZSTDv05_strategy;
73
+ typedef struct {
74
+ U64 srcSize;
75
+ U32 windowLog; /* the only useful information to retrieve */
76
+ U32 contentLog; U32 hashLog; U32 searchLog; U32 searchLength; U32 targetLength; ZSTDv05_strategy strategy;
77
+ } ZSTDv05_parameters;
78
+ size_t ZSTDv05_getFrameParams(ZSTDv05_parameters* params, const void* src, size_t srcSize);
79
+
80
+ size_t ZSTDv05_decompressBegin_usingDict(ZSTDv05_DCtx* dctx, const void* dict, size_t dictSize);
81
+ void ZSTDv05_copyDCtx(ZSTDv05_DCtx* dstDCtx, const ZSTDv05_DCtx* srcDCtx);
82
+ size_t ZSTDv05_nextSrcSizeToDecompress(ZSTDv05_DCtx* dctx);
83
+ size_t ZSTDv05_decompressContinue(ZSTDv05_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
84
+
85
+
86
+ /*-***********************
87
+ * ZBUFF API
88
+ *************************/
89
+ typedef struct ZBUFFv05_DCtx_s ZBUFFv05_DCtx;
90
+ ZBUFFv05_DCtx* ZBUFFv05_createDCtx(void);
91
+ size_t ZBUFFv05_freeDCtx(ZBUFFv05_DCtx* dctx);
92
+
93
+ size_t ZBUFFv05_decompressInit(ZBUFFv05_DCtx* dctx);
94
+ size_t ZBUFFv05_decompressInitDictionary(ZBUFFv05_DCtx* dctx, const void* dict, size_t dictSize);
95
+
96
+ size_t ZBUFFv05_decompressContinue(ZBUFFv05_DCtx* dctx,
97
+ void* dst, size_t* dstCapacityPtr,
98
+ const void* src, size_t* srcSizePtr);
99
+
100
+ /*-***************************************************************************
101
+ * Streaming decompression
102
+ *
103
+ * A ZBUFFv05_DCtx object is required to track streaming operations.
104
+ * Use ZBUFFv05_createDCtx() and ZBUFFv05_freeDCtx() to create/release resources.
105
+ * Use ZBUFFv05_decompressInit() to start a new decompression operation,
106
+ * or ZBUFFv05_decompressInitDictionary() if decompression requires a dictionary.
107
+ * Note that ZBUFFv05_DCtx objects can be reused multiple times.
108
+ *
109
+ * Use ZBUFFv05_decompressContinue() repetitively to consume your input.
110
+ * *srcSizePtr and *dstCapacityPtr can be any size.
111
+ * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
112
+ * Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
113
+ * The content of @dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change @dst.
114
+ * @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to help latency)
115
+ * or 0 when a frame is completely decoded
116
+ * or an error code, which can be tested using ZBUFFv05_isError().
117
+ *
118
+ * Hint : recommended buffer sizes (not compulsory) : ZBUFFv05_recommendedDInSize() / ZBUFFv05_recommendedDOutSize()
119
+ * output : ZBUFFv05_recommendedDOutSize==128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
120
+ * input : ZBUFFv05_recommendedDInSize==128Kb+3; just follow indications from ZBUFFv05_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
121
+ * *******************************************************************************/
122
+
123
+
124
+ /* *************************************
125
+ * Tool functions
126
+ ***************************************/
127
+ unsigned ZBUFFv05_isError(size_t errorCode);
128
+ const char* ZBUFFv05_getErrorName(size_t errorCode);
129
+
130
+ /** Functions below provide recommended buffer sizes for Compression or Decompression operations.
131
+ * These sizes are just hints, and tend to offer better latency */
132
+ size_t ZBUFFv05_recommendedDInSize(void);
133
+ size_t ZBUFFv05_recommendedDOutSize(void);
134
+
135
+
136
+
137
+ /*-*************************************
138
+ * Constants
139
+ ***************************************/
140
+ #define ZSTDv05_MAGICNUMBER 0xFD2FB525 /* v0.5 */
141
+
142
+
143
+
144
+
145
+ #if defined (__cplusplus)
146
+ }
147
+ #endif
148
+
149
+ #endif /* ZSTDv0505_H */