Fixed : dictBuilder fails if first sample is too small
This commit is contained in:
@@ -584,12 +584,15 @@ static void ZDICT_countEStats(EStats_ress_t esr,
|
|||||||
U32* countLit, U32* offsetcodeCount, U32* matchlengthCount, U32* litlengthCount, U32* repOffsets,
|
U32* countLit, U32* offsetcodeCount, U32* matchlengthCount, U32* litlengthCount, U32* repOffsets,
|
||||||
const void* src, size_t srcSize)
|
const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
const seqStore_t* seqStorePtr;
|
size_t cSize;
|
||||||
|
|
||||||
if (srcSize > ZSTD_BLOCKSIZE_MAX) srcSize = ZSTD_BLOCKSIZE_MAX; /* protection vs large samples */
|
if (srcSize > ZSTD_BLOCKSIZE_MAX) srcSize = ZSTD_BLOCKSIZE_MAX; /* protection vs large samples */
|
||||||
ZSTD_copyCCtx(esr.zc, esr.ref);
|
ZSTD_copyCCtx(esr.zc, esr.ref);
|
||||||
ZSTD_compressBlock(esr.zc, esr.workPlace, ZSTD_BLOCKSIZE_MAX, src, srcSize);
|
cSize = ZSTD_compressBlock(esr.zc, esr.workPlace, ZSTD_BLOCKSIZE_MAX, src, srcSize);
|
||||||
seqStorePtr = ZSTD_getSeqStore(esr.zc);
|
if (ZSTD_isError(cSize)) { DISPLAYLEVEL(1, "warning : could not compress sample size %u \n", (U32)srcSize); return; }
|
||||||
|
|
||||||
|
if (cSize) { /* if == 0; block is not compressible */
|
||||||
|
const seqStore_t* seqStorePtr = ZSTD_getSeqStore(esr.zc);
|
||||||
|
|
||||||
/* literals stats */
|
/* literals stats */
|
||||||
{ const BYTE* bytePtr;
|
{ const BYTE* bytePtr;
|
||||||
@@ -625,7 +628,7 @@ static void ZDICT_countEStats(EStats_ress_t esr,
|
|||||||
repOffsets[offset1] += 3;
|
repOffsets[offset1] += 3;
|
||||||
repOffsets[offset2] += 1;
|
repOffsets[offset2] += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user