record long offsets in ZSTD_symbolEncodingTypeStats_t + add test case
This commit is contained in:
@@ -186,7 +186,6 @@ BYTE SEQUENCE_LITERAL_BUFFER[ZSTD_BLOCKSIZE_MAX]; /* storeSeq expects a place to
|
||||
BYTE SEQUENCE_LLCODE[ZSTD_BLOCKSIZE_MAX];
|
||||
BYTE SEQUENCE_MLCODE[ZSTD_BLOCKSIZE_MAX];
|
||||
BYTE SEQUENCE_OFCODE[ZSTD_BLOCKSIZE_MAX];
|
||||
BYTE SEQUENCE_LONGOFFSETS[1];
|
||||
|
||||
U64 WKSP[HUF_WORKSPACE_SIZE_U64];
|
||||
|
||||
@@ -635,7 +634,6 @@ static inline void initSeqStore(seqStore_t *seqStore) {
|
||||
seqStore->llCode = SEQUENCE_LLCODE;
|
||||
seqStore->mlCode = SEQUENCE_MLCODE;
|
||||
seqStore->ofCode = SEQUENCE_OFCODE;
|
||||
seqStore->longOffsets = SEQUENCE_LONGOFFSETS;
|
||||
|
||||
ZSTD_resetSeqStore(seqStore);
|
||||
}
|
||||
|
||||
@@ -2222,6 +2222,66 @@ static int basicUnitTests(U32 seed, double compressibility, int bigTests)
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : Testing large offset with small window size: ", testNb++);
|
||||
{
|
||||
ZSTD_CCtx* cctx = ZSTD_createCCtx();
|
||||
ZSTD_DCtx* dctx = ZSTD_createDCtx();
|
||||
|
||||
/* Test large offset, small window size*/
|
||||
{
|
||||
size_t srcSize = 21;
|
||||
void* const src = CNBuffer;
|
||||
size_t dstSize = ZSTD_compressBound(srcSize);
|
||||
void* const dst = compressedBuffer;
|
||||
size_t const kNbSequences = 4;
|
||||
ZSTD_Sequence* sequences = malloc(sizeof(ZSTD_Sequence) * kNbSequences);
|
||||
void* const checkBuf = malloc(srcSize);
|
||||
const size_t largeDictSize = 1 << 30;
|
||||
ZSTD_CDict* cdict = NULL;
|
||||
ZSTD_DDict* ddict = NULL;
|
||||
|
||||
/* Generate large dictionary */
|
||||
void* dictBuffer = calloc(largeDictSize, 1);
|
||||
ZSTD_compressionParameters cParams = ZSTD_getCParams(1, srcSize, largeDictSize);
|
||||
cParams.minMatch = ZSTD_MINMATCH_MIN;
|
||||
cParams.hashLog = ZSTD_HASHLOG_MIN;
|
||||
cParams.chainLog = ZSTD_CHAINLOG_MIN;
|
||||
|
||||
cdict = ZSTD_createCDict_advanced(dictBuffer, largeDictSize, ZSTD_dlm_byRef, ZSTD_dct_rawContent, cParams, ZSTD_defaultCMem);
|
||||
ddict = ZSTD_createDDict_advanced(dictBuffer, largeDictSize, ZSTD_dlm_byRef, ZSTD_dct_rawContent, ZSTD_defaultCMem);
|
||||
|
||||
ZSTD_CCtx_refCDict(cctx, cdict);
|
||||
ZSTD_DCtx_refDDict(dctx, ddict);
|
||||
|
||||
sequences[0] = (ZSTD_Sequence) {3, 3, 3, 0};
|
||||
sequences[1] = (ZSTD_Sequence) {1 << 29, 0, 3, 0};
|
||||
sequences[2] = (ZSTD_Sequence) {1 << 29, 0, 9, 0};
|
||||
sequences[3] = (ZSTD_Sequence) {3, 0, 3, 0};
|
||||
|
||||
cSize = ZSTD_compressSequences(cctx, dst, dstSize,
|
||||
sequences, kNbSequences,
|
||||
src, srcSize);
|
||||
|
||||
CHECK(ZSTD_isError(cSize), "Should not throw an error");
|
||||
|
||||
{
|
||||
size_t dSize = ZSTD_decompressDCtx(dctx, checkBuf, srcSize, dst, cSize);
|
||||
CHECK(ZSTD_isError(dSize), "Should not throw an error");
|
||||
CHECK(memcmp(src, checkBuf, srcSize) != 0, "Corruption!");
|
||||
}
|
||||
|
||||
free(sequences);
|
||||
free(checkBuf);
|
||||
free(dictBuffer);
|
||||
ZSTD_freeCDict(cdict);
|
||||
ZSTD_freeDDict(ddict);
|
||||
}
|
||||
ZSTD_freeCCtx(cctx);
|
||||
ZSTD_freeDCtx(dctx);
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
_end:
|
||||
FUZ_freeDictionary(dictionary);
|
||||
ZSTD_freeCStream(zc);
|
||||
|
||||
Reference in New Issue
Block a user