fileio uses ZSTD_resetDStream()
This commit is contained in:
parent
e91c4b4cef
commit
3ecbe6a37c
@ -480,8 +480,6 @@ typedef struct {
|
|||||||
size_t srcBufferSize;
|
size_t srcBufferSize;
|
||||||
void* dstBuffer;
|
void* dstBuffer;
|
||||||
size_t dstBufferSize;
|
size_t dstBufferSize;
|
||||||
void* dictBuffer;
|
|
||||||
size_t dictBufferSize;
|
|
||||||
ZSTD_DStream* dctx;
|
ZSTD_DStream* dctx;
|
||||||
FILE* dstFile;
|
FILE* dstFile;
|
||||||
} dRess_t;
|
} dRess_t;
|
||||||
@ -501,7 +499,12 @@ static dRess_t FIO_createDResources(const char* dictFileName)
|
|||||||
if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(61, "Allocation error : not enough memory");
|
if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(61, "Allocation error : not enough memory");
|
||||||
|
|
||||||
/* dictionary */
|
/* dictionary */
|
||||||
ress.dictBufferSize = FIO_loadFile(&(ress.dictBuffer), dictFileName);
|
{ void* dictBuffer;
|
||||||
|
size_t const dictBufferSize = FIO_loadFile(&dictBuffer, dictFileName);
|
||||||
|
size_t const initError = ZSTD_initDStream_usingDict(ress.dctx, dictBuffer, dictBufferSize);
|
||||||
|
if (ZSTD_isError(initError)) EXM_THROW(61, "ZSTD_initDStream_usingDict error : %s", ZSTD_getErrorName(initError));
|
||||||
|
free(dictBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
return ress;
|
return ress;
|
||||||
}
|
}
|
||||||
@ -512,7 +515,6 @@ static void FIO_freeDResources(dRess_t ress)
|
|||||||
if (ZSTD_isError(errorCode)) EXM_THROW(69, "Error : can't free ZSTD_DStream context resource : %s", ZSTD_getErrorName(errorCode));
|
if (ZSTD_isError(errorCode)) EXM_THROW(69, "Error : can't free ZSTD_DStream context resource : %s", ZSTD_getErrorName(errorCode));
|
||||||
free(ress.srcBuffer);
|
free(ress.srcBuffer);
|
||||||
free(ress.dstBuffer);
|
free(ress.dstBuffer);
|
||||||
free(ress.dictBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -601,7 +603,7 @@ unsigned long long FIO_decompressFrame(dRess_t ress,
|
|||||||
size_t readSize;
|
size_t readSize;
|
||||||
U32 storedSkips = 0;
|
U32 storedSkips = 0;
|
||||||
|
|
||||||
ZSTD_initDStream_usingDict(ress.dctx, ress.dictBuffer, ress.dictBufferSize);
|
ZSTD_resetDStream(ress.dctx);
|
||||||
|
|
||||||
/* Header loading (optional, saves one loop) */
|
/* Header loading (optional, saves one loop) */
|
||||||
{ size_t const toLoad = 9 - alreadyLoaded; /* assumption : 9 >= alreadyLoaded */
|
{ size_t const toLoad = 9 - alreadyLoaded; /* assumption : 9 >= alreadyLoaded */
|
||||||
|
@ -205,7 +205,7 @@ $MD5SUM dirTestDict/* > tmph1
|
|||||||
$ZSTD -f --rm dirTestDict/* -D tmpDictC
|
$ZSTD -f --rm dirTestDict/* -D tmpDictC
|
||||||
$ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
|
$ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
$ECHO "test skipped on OS-X" # not compatible with OS-X's md5
|
$ECHO "md5sum -c not supported on OS-X : test skipped" # not compatible with OS-X's md5
|
||||||
else
|
else
|
||||||
$MD5SUM -c tmph1
|
$MD5SUM -c tmph1
|
||||||
fi
|
fi
|
||||||
|
@ -209,7 +209,8 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
|
|||||||
|
|
||||||
/* Byte-by-byte decompression test */
|
/* Byte-by-byte decompression test */
|
||||||
DISPLAYLEVEL(4, "test%3i : decompress byte-by-byte : ", testNb++);
|
DISPLAYLEVEL(4, "test%3i : decompress byte-by-byte : ", testNb++);
|
||||||
{ size_t r = 1;
|
{ /* skippable frame */
|
||||||
|
size_t r = 1;
|
||||||
ZSTD_initDStream_usingDict(zd, CNBuffer, 128 KB);
|
ZSTD_initDStream_usingDict(zd, CNBuffer, 128 KB);
|
||||||
inBuff.src = compressedBuffer;
|
inBuff.src = compressedBuffer;
|
||||||
outBuff.dst = decodedBuffer;
|
outBuff.dst = decodedBuffer;
|
||||||
@ -221,9 +222,10 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
|
|||||||
r = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
r = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||||
if (ZSTD_isError(r)) goto _output_error;
|
if (ZSTD_isError(r)) goto _output_error;
|
||||||
}
|
}
|
||||||
|
/* normal frame */
|
||||||
ZSTD_initDStream_usingDict(zd, CNBuffer, 128 KB);
|
ZSTD_initDStream_usingDict(zd, CNBuffer, 128 KB);
|
||||||
r=1;
|
r=1;
|
||||||
while (r) { /* normal frame */
|
while (r) {
|
||||||
inBuff.size = inBuff.pos + 1;
|
inBuff.size = inBuff.pos + 1;
|
||||||
outBuff.size = outBuff.pos + 1;
|
outBuff.size = outBuff.pos + 1;
|
||||||
r = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
r = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||||
@ -322,6 +324,8 @@ _output_error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ====== Fuzzer tests ====== */
|
||||||
|
|
||||||
static size_t findDiff(const void* buf1, const void* buf2, size_t max)
|
static size_t findDiff(const void* buf1, const void* buf2, size_t max)
|
||||||
{
|
{
|
||||||
const BYTE* b1 = (const BYTE*)buf1;
|
const BYTE* b1 = (const BYTE*)buf1;
|
||||||
@ -413,8 +417,8 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
lseed = coreSeed ^ prime1;
|
lseed = coreSeed ^ prime1;
|
||||||
|
|
||||||
/* states full reset (unsynchronized) */
|
/* states full reset (deliberately not synchronized) */
|
||||||
/* some issues only happen when reusing states in a specific sequence of parameters */
|
/* some issues can only happen when reusing states */
|
||||||
if ((FUZ_rand(&lseed) & 0xFF) == 131) { ZSTD_freeCStream(zc); zc = ZSTD_createCStream(); }
|
if ((FUZ_rand(&lseed) & 0xFF) == 131) { ZSTD_freeCStream(zc); zc = ZSTD_createCStream(); }
|
||||||
if ((FUZ_rand(&lseed) & 0xFF) == 132) { ZSTD_freeDStream(zd); zd = ZSTD_createDStream(); }
|
if ((FUZ_rand(&lseed) & 0xFF) == 132) { ZSTD_freeDStream(zd); zd = ZSTD_createDStream(); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user