zstd-ruby 1.2.0.0 → 1.3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/zstdruby/libzstd/Makefile +7 -5
- data/ext/zstdruby/libzstd/common/bitstream.h +23 -9
- data/ext/zstdruby/libzstd/common/error_private.c +4 -1
- data/ext/zstdruby/libzstd/common/huf.h +20 -0
- data/ext/zstdruby/libzstd/common/mem.h +0 -14
- data/ext/zstdruby/libzstd/common/pool.c +12 -0
- data/ext/zstdruby/libzstd/common/pool.h +5 -0
- data/ext/zstdruby/libzstd/common/threading.c +0 -1
- data/ext/zstdruby/libzstd/common/zstd_common.c +25 -18
- data/ext/zstdruby/libzstd/common/zstd_errors.h +15 -7
- data/ext/zstdruby/libzstd/common/zstd_internal.h +59 -9
- data/ext/zstdruby/libzstd/compress/huf_compress.c +7 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1082 -487
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +30 -15
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +362 -158
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +49 -13
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +150 -26
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +380 -258
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +23 -37
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +30 -40
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +104 -95
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +11 -10
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +14 -19
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +13 -12
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +13 -14
- data/ext/zstdruby/libzstd/zstd.h +507 -166
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37d33e2de9a2f6792e4ed617a0015414c939e27
|
4
|
+
data.tar.gz: 284159f8db3f657c3152bf9a33d9982614815f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3369c26e404a541ca0e1f1c7ce8e23d801a74ee5aacc1e22ed3f77dea3573109100f824551ed4ea16659b2d6690d22f5f3665e2ff84ca48d514dd302999be13
|
7
|
+
data.tar.gz: '07911cc0475213a4898781a0b7a3ae29ed195e443a4fe2531c8affaf2307edeb6523252079c650573b769b7ce12209ffe08b5e605ca948829463d6604300b1e0'
|
data/README.md
CHANGED
@@ -22,9 +22,11 @@ VERSION?= $(LIBVER)
|
|
22
22
|
|
23
23
|
CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
|
24
24
|
CFLAGS ?= -O3
|
25
|
-
DEBUGFLAGS = -
|
26
|
-
|
27
|
-
|
25
|
+
DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
26
|
+
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
27
|
+
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
|
28
|
+
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
29
|
+
-Wredundant-decls
|
28
30
|
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
29
31
|
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
30
32
|
|
@@ -71,7 +73,7 @@ libzstd.a: $(ZSTD_OBJ)
|
|
71
73
|
@echo compiling static library
|
72
74
|
@$(AR) $(ARFLAGS) $@ $^
|
73
75
|
|
74
|
-
libzstd.a-mt: CPPFLAGS += -
|
76
|
+
libzstd.a-mt: CPPFLAGS += -DZSTD_MULTITHREAD
|
75
77
|
libzstd.a-mt: libzstd.a
|
76
78
|
|
77
79
|
$(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
|
@@ -147,7 +149,7 @@ install: libzstd.a libzstd libzstd.pc
|
|
147
149
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ $(DESTDIR)$(INCLUDEDIR)/
|
148
150
|
@$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
149
151
|
@echo Installing libraries
|
150
|
-
@$(
|
152
|
+
@$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
151
153
|
@$(INSTALL_LIB) libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
|
152
154
|
@ln -sf libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
153
155
|
@ln -sf libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
@@ -39,7 +39,6 @@
|
|
39
39
|
extern "C" {
|
40
40
|
#endif
|
41
41
|
|
42
|
-
|
43
42
|
/*
|
44
43
|
* This API consists of small unitary functions, which must be inlined for best performance.
|
45
44
|
* Since link-time-optimization is not available for all compilers,
|
@@ -59,7 +58,9 @@ extern "C" {
|
|
59
58
|
#if defined(BIT_DEBUG) && (BIT_DEBUG>=1)
|
60
59
|
# include <assert.h>
|
61
60
|
#else
|
62
|
-
#
|
61
|
+
# ifndef assert
|
62
|
+
# define assert(condition) ((void)0)
|
63
|
+
# endif
|
63
64
|
#endif
|
64
65
|
|
65
66
|
|
@@ -74,6 +75,7 @@ extern "C" {
|
|
74
75
|
#define STREAM_ACCUMULATOR_MIN_64 57
|
75
76
|
#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
|
76
77
|
|
78
|
+
|
77
79
|
/*-******************************************
|
78
80
|
* bitStream encoding API (write forward)
|
79
81
|
********************************************/
|
@@ -303,13 +305,25 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
|
|
303
305
|
bitD->bitContainer = *(const BYTE*)(bitD->start);
|
304
306
|
switch(srcSize)
|
305
307
|
{
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
308
|
+
case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
|
309
|
+
/* fall-through */
|
310
|
+
|
311
|
+
case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
|
312
|
+
/* fall-through */
|
313
|
+
|
314
|
+
case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
|
315
|
+
/* fall-through */
|
316
|
+
|
317
|
+
case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
|
318
|
+
/* fall-through */
|
319
|
+
|
320
|
+
case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
|
321
|
+
/* fall-through */
|
322
|
+
|
323
|
+
case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
|
324
|
+
/* fall-through */
|
325
|
+
|
326
|
+
default: break;
|
313
327
|
}
|
314
328
|
{ BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
|
315
329
|
bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
|
@@ -24,7 +24,8 @@ const char* ERR_getErrorString(ERR_enum code)
|
|
24
24
|
case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
|
25
25
|
case PREFIX(frameParameter_unsupportedBy32bits): return "Frame parameter unsupported in 32-bits mode";
|
26
26
|
case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
|
27
|
-
case PREFIX(compressionParameter_unsupported): return "Compression parameter is
|
27
|
+
case PREFIX(compressionParameter_unsupported): return "Compression parameter is not supported";
|
28
|
+
case PREFIX(compressionParameter_outOfBound): return "Compression parameter is out of bound";
|
28
29
|
case PREFIX(init_missing): return "Context should be init first";
|
29
30
|
case PREFIX(memory_allocation): return "Allocation error : not enough memory";
|
30
31
|
case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
|
@@ -38,6 +39,8 @@ const char* ERR_getErrorString(ERR_enum code)
|
|
38
39
|
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
|
39
40
|
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
|
40
41
|
case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
|
42
|
+
case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
|
43
|
+
case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
|
41
44
|
case PREFIX(maxCode):
|
42
45
|
default: return notErrorCode;
|
43
46
|
}
|
@@ -111,6 +111,18 @@ HUF_PUBLIC_API size_t HUF_compress2 (void* dst, size_t dstCapacity, const void*
|
|
111
111
|
#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32))
|
112
112
|
HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
|
113
113
|
|
114
|
+
/**
|
115
|
+
* The minimum workspace size for the `workSpace` used in
|
116
|
+
* HUF_readDTableX2_wksp() and HUF_readDTableX4_wksp().
|
117
|
+
*
|
118
|
+
* The space used depends on HUF_TABLELOG_MAX, ranging from ~1500 bytes when
|
119
|
+
* HUF_TABLE_LOG_MAX=12 to ~1850 bytes when HUF_TABLE_LOG_MAX=15.
|
120
|
+
* Buffer overflow errors may potentially occur if code modifications result in
|
121
|
+
* a required workspace size greater than that specified in the following
|
122
|
+
* macro.
|
123
|
+
*/
|
124
|
+
#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10)
|
125
|
+
#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
|
114
126
|
|
115
127
|
|
116
128
|
/* ******************************************************************
|
@@ -170,8 +182,11 @@ size_t HUF_decompress4X4 (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
170
182
|
|
171
183
|
size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< decodes RLE and uncompressed */
|
172
184
|
size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */
|
185
|
+
size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */
|
173
186
|
size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
|
187
|
+
size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
|
174
188
|
size_t HUF_decompress4X4_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
|
189
|
+
size_t HUF_decompress4X4_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
|
175
190
|
|
176
191
|
|
177
192
|
/* ****************************************
|
@@ -243,7 +258,9 @@ HUF_decompress() does the following:
|
|
243
258
|
U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize);
|
244
259
|
|
245
260
|
size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize);
|
261
|
+
size_t HUF_readDTableX2_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
|
246
262
|
size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize);
|
263
|
+
size_t HUF_readDTableX4_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
|
247
264
|
|
248
265
|
size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
|
249
266
|
size_t HUF_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
|
@@ -266,8 +283,11 @@ size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
266
283
|
size_t HUF_decompress1X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */
|
267
284
|
|
268
285
|
size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
|
286
|
+
size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize);
|
269
287
|
size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
|
288
|
+
size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
|
270
289
|
size_t HUF_decompress1X4_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
|
290
|
+
size_t HUF_decompress1X4_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
|
271
291
|
|
272
292
|
size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */
|
273
293
|
size_t HUF_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
|
@@ -352,20 +352,6 @@ MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
|
|
352
352
|
}
|
353
353
|
|
354
354
|
|
355
|
-
/* function safe only for comparisons */
|
356
|
-
MEM_STATIC U32 MEM_readMINMATCH(const void* memPtr, U32 length)
|
357
|
-
{
|
358
|
-
switch (length)
|
359
|
-
{
|
360
|
-
default :
|
361
|
-
case 4 : return MEM_read32(memPtr);
|
362
|
-
case 3 : if (MEM_isLittleEndian())
|
363
|
-
return MEM_read32(memPtr)<<8;
|
364
|
-
else
|
365
|
-
return MEM_read32(memPtr)>>8;
|
366
|
-
}
|
367
|
-
}
|
368
|
-
|
369
355
|
#if defined (__cplusplus)
|
370
356
|
}
|
371
357
|
#endif
|
@@ -146,6 +146,13 @@ void POOL_free(POOL_ctx *ctx) {
|
|
146
146
|
free(ctx);
|
147
147
|
}
|
148
148
|
|
149
|
+
size_t POOL_sizeof(POOL_ctx *ctx) {
|
150
|
+
if (ctx==NULL) return 0; /* supports sizeof NULL */
|
151
|
+
return sizeof(*ctx)
|
152
|
+
+ ctx->queueSize * sizeof(POOL_job)
|
153
|
+
+ ctx->numThreads * sizeof(pthread_t);
|
154
|
+
}
|
155
|
+
|
149
156
|
void POOL_add(void *ctxVoid, POOL_function function, void *opaque) {
|
150
157
|
POOL_ctx *ctx = (POOL_ctx *)ctxVoid;
|
151
158
|
if (!ctx) { return; }
|
@@ -191,4 +198,9 @@ void POOL_add(void *ctx, POOL_function function, void *opaque) {
|
|
191
198
|
function(opaque);
|
192
199
|
}
|
193
200
|
|
201
|
+
size_t POOL_sizeof(POOL_ctx *ctx) {
|
202
|
+
if (ctx==NULL) return 0; /* supports sizeof NULL */
|
203
|
+
return sizeof(*ctx);
|
204
|
+
}
|
205
|
+
|
194
206
|
#endif /* ZSTD_MULTITHREAD */
|
@@ -32,6 +32,11 @@ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize);
|
|
32
32
|
*/
|
33
33
|
void POOL_free(POOL_ctx *ctx);
|
34
34
|
|
35
|
+
/*! POOL_sizeof() :
|
36
|
+
return memory usage of pool returned by POOL_create().
|
37
|
+
*/
|
38
|
+
size_t POOL_sizeof(POOL_ctx *ctx);
|
39
|
+
|
35
40
|
/*! POOL_function :
|
36
41
|
The function type that can be added to a thread pool.
|
37
42
|
*/
|
@@ -12,16 +12,19 @@
|
|
12
12
|
/*-*************************************
|
13
13
|
* Dependencies
|
14
14
|
***************************************/
|
15
|
-
#include <stdlib.h>
|
15
|
+
#include <stdlib.h> /* malloc, calloc, free */
|
16
|
+
#include <string.h> /* memset */
|
16
17
|
#include "error_private.h"
|
17
18
|
#define ZSTD_STATIC_LINKING_ONLY
|
18
|
-
#include "zstd.h"
|
19
|
+
#include "zstd.h"
|
19
20
|
|
20
21
|
|
21
22
|
/*-****************************************
|
22
23
|
* Version
|
23
24
|
******************************************/
|
24
|
-
unsigned ZSTD_versionNumber
|
25
|
+
unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
|
26
|
+
|
27
|
+
const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
|
25
28
|
|
26
29
|
|
27
30
|
/*-****************************************
|
@@ -47,27 +50,31 @@ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString
|
|
47
50
|
/*=**************************************************************
|
48
51
|
* Custom allocator
|
49
52
|
****************************************************************/
|
50
|
-
|
51
|
-
void* ZSTD_defaultAllocFunction(void* opaque, size_t size)
|
52
|
-
{
|
53
|
-
void* address = malloc(size);
|
54
|
-
(void)opaque;
|
55
|
-
return address;
|
56
|
-
}
|
57
|
-
|
58
|
-
void ZSTD_defaultFreeFunction(void* opaque, void* address)
|
53
|
+
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
|
59
54
|
{
|
60
|
-
(
|
61
|
-
|
55
|
+
if (customMem.customAlloc)
|
56
|
+
return customMem.customAlloc(customMem.opaque, size);
|
57
|
+
return malloc(size);
|
62
58
|
}
|
63
59
|
|
64
|
-
void*
|
60
|
+
void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
|
65
61
|
{
|
66
|
-
|
62
|
+
if (customMem.customAlloc) {
|
63
|
+
/* calloc implemented as malloc+memset;
|
64
|
+
* not as efficient as calloc, but next best guess for custom malloc */
|
65
|
+
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
66
|
+
memset(ptr, 0, size);
|
67
|
+
return ptr;
|
68
|
+
}
|
69
|
+
return calloc(1, size);
|
67
70
|
}
|
68
71
|
|
69
72
|
void ZSTD_free(void* ptr, ZSTD_customMem customMem)
|
70
73
|
{
|
71
|
-
if (ptr!=NULL)
|
72
|
-
customMem.customFree
|
74
|
+
if (ptr!=NULL) {
|
75
|
+
if (customMem.customFree)
|
76
|
+
customMem.customFree(customMem.opaque, ptr);
|
77
|
+
else
|
78
|
+
free(ptr);
|
79
|
+
}
|
73
80
|
}
|
@@ -19,10 +19,12 @@ extern "C" {
|
|
19
19
|
|
20
20
|
|
21
21
|
/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
22
|
+
#ifndef ZSTDERRORLIB_VISIBILITY
|
23
|
+
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
24
|
+
# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
|
25
|
+
# else
|
26
|
+
# define ZSTDERRORLIB_VISIBILITY
|
27
|
+
# endif
|
26
28
|
#endif
|
27
29
|
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
28
30
|
# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
|
@@ -33,8 +35,11 @@ extern "C" {
|
|
33
35
|
#endif
|
34
36
|
|
35
37
|
/*-****************************************
|
36
|
-
* error codes list
|
37
|
-
|
38
|
+
* error codes list
|
39
|
+
* note : this API is still considered unstable
|
40
|
+
* it should not be used with a dynamic library
|
41
|
+
* only static linking is allowed
|
42
|
+
******************************************/
|
38
43
|
typedef enum {
|
39
44
|
ZSTD_error_no_error,
|
40
45
|
ZSTD_error_GENERIC,
|
@@ -45,6 +50,7 @@ typedef enum {
|
|
45
50
|
ZSTD_error_frameParameter_unsupportedBy32bits,
|
46
51
|
ZSTD_error_frameParameter_windowTooLarge,
|
47
52
|
ZSTD_error_compressionParameter_unsupported,
|
53
|
+
ZSTD_error_compressionParameter_outOfBound,
|
48
54
|
ZSTD_error_init_missing,
|
49
55
|
ZSTD_error_memory_allocation,
|
50
56
|
ZSTD_error_stage_wrong,
|
@@ -58,12 +64,14 @@ typedef enum {
|
|
58
64
|
ZSTD_error_dictionary_corrupted,
|
59
65
|
ZSTD_error_dictionary_wrong,
|
60
66
|
ZSTD_error_dictionaryCreation_failed,
|
67
|
+
ZSTD_error_frameIndex_tooLarge,
|
68
|
+
ZSTD_error_seekableIO,
|
61
69
|
ZSTD_error_maxCode
|
62
70
|
} ZSTD_ErrorCode;
|
63
71
|
|
64
72
|
/*! ZSTD_getErrorCode() :
|
65
73
|
convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
|
66
|
-
which can be used to compare
|
74
|
+
which can be used to compare with enum list published above */
|
67
75
|
ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
|
68
76
|
ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);
|
69
77
|
|
@@ -18,6 +18,7 @@
|
|
18
18
|
# include <intrin.h> /* For Visual 2005 */
|
19
19
|
# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
|
20
20
|
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
21
|
+
# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
|
21
22
|
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
22
23
|
#else
|
23
24
|
# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
@@ -50,9 +51,42 @@
|
|
50
51
|
#define ZSTD_STATIC_LINKING_ONLY
|
51
52
|
#include "zstd.h"
|
52
53
|
#ifndef XXH_STATIC_LINKING_ONLY
|
53
|
-
# define XXH_STATIC_LINKING_ONLY
|
54
|
+
# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
55
|
+
#endif
|
56
|
+
#include "xxhash.h" /* XXH_reset, update, digest */
|
57
|
+
|
58
|
+
|
59
|
+
/*-*************************************
|
60
|
+
* Debug
|
61
|
+
***************************************/
|
62
|
+
#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
|
63
|
+
# include <assert.h>
|
64
|
+
#else
|
65
|
+
# ifndef assert
|
66
|
+
# define assert(condition) ((void)0)
|
67
|
+
# endif
|
68
|
+
#endif
|
69
|
+
|
70
|
+
#define ZSTD_STATIC_ASSERT(c) { enum { ZSTD_static_assert = 1/(int)(!!(c)) }; }
|
71
|
+
|
72
|
+
#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
|
73
|
+
# include <stdio.h>
|
74
|
+
/* recommended values for ZSTD_DEBUG display levels :
|
75
|
+
* 1 : no display, enables assert() only
|
76
|
+
* 2 : reserved for currently active debugging path
|
77
|
+
* 3 : events once per object lifetime (CCtx, CDict)
|
78
|
+
* 4 : events once per frame
|
79
|
+
* 5 : events once per block
|
80
|
+
* 6 : events once per sequence (*very* verbose) */
|
81
|
+
# define DEBUGLOG(l, ...) { \
|
82
|
+
if (l<=ZSTD_DEBUG) { \
|
83
|
+
fprintf(stderr, __FILE__ ": "); \
|
84
|
+
fprintf(stderr, __VA_ARGS__); \
|
85
|
+
fprintf(stderr, " \n"); \
|
86
|
+
} }
|
87
|
+
#else
|
88
|
+
# define DEBUGLOG(l, ...) {} /* disabled */
|
54
89
|
#endif
|
55
|
-
#include "xxhash.h" /* XXH_reset, update, digest */
|
56
90
|
|
57
91
|
|
58
92
|
/*-*************************************
|
@@ -70,7 +104,6 @@
|
|
70
104
|
* Common constants
|
71
105
|
***************************************/
|
72
106
|
#define ZSTD_OPT_NUM (1<<12)
|
73
|
-
#define ZSTD_DICT_MAGIC 0xEC30A437 /* v0.7+ */
|
74
107
|
|
75
108
|
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
76
109
|
#define ZSTD_REP_CHECK (ZSTD_REP_NUM) /* number of repcodes to check by the optimal parser */
|
@@ -235,15 +268,10 @@ typedef struct {
|
|
235
268
|
|
236
269
|
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx);
|
237
270
|
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr);
|
238
|
-
int ZSTD_isSkipFrame(ZSTD_DCtx* dctx);
|
239
271
|
|
240
272
|
/* custom memory allocation functions */
|
241
|
-
void* ZSTD_defaultAllocFunction(void* opaque, size_t size);
|
242
|
-
void ZSTD_defaultFreeFunction(void* opaque, void* address);
|
243
|
-
#ifndef ZSTD_DLL_IMPORT
|
244
|
-
static const ZSTD_customMem defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL };
|
245
|
-
#endif
|
246
273
|
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
|
274
|
+
void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
|
247
275
|
void ZSTD_free(void* ptr, ZSTD_customMem customMem);
|
248
276
|
|
249
277
|
|
@@ -281,4 +309,26 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
|
|
281
309
|
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx);
|
282
310
|
|
283
311
|
|
312
|
+
/*! ZSTD_initCStream_internal() :
|
313
|
+
* Private use only. Init streaming operation.
|
314
|
+
* expects params to be valid.
|
315
|
+
* must receive dict, or cdict, or none, but not both.
|
316
|
+
* @return : 0, or an error code */
|
317
|
+
size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
|
318
|
+
const void* dict, size_t dictSize,
|
319
|
+
const ZSTD_CDict* cdict,
|
320
|
+
ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
321
|
+
|
322
|
+
/*! ZSTD_compressStream_generic() :
|
323
|
+
* Private use only. To be called from zstdmt_compress.c in single-thread mode. */
|
324
|
+
size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
325
|
+
ZSTD_outBuffer* output,
|
326
|
+
ZSTD_inBuffer* input,
|
327
|
+
ZSTD_EndDirective const flushMode);
|
328
|
+
|
329
|
+
/*! ZSTD_getParamsFromCDict() :
|
330
|
+
* as the name implies */
|
331
|
+
ZSTD_parameters ZSTD_getParamsFromCDict(const ZSTD_CDict* cdict);
|
332
|
+
|
333
|
+
|
284
334
|
#endif /* ZSTD_CCOMMON_H_MODULE */
|