added test of new parameter ZSTD_p_forceWindow
This commit is contained in:
@@ -123,7 +123,7 @@ size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned
|
|||||||
{
|
{
|
||||||
switch(param)
|
switch(param)
|
||||||
{
|
{
|
||||||
case ZSTD_p_forceWindow : cctx->forceWindow = value; return 0;
|
case ZSTD_p_forceWindow : cctx->forceWindow = value>0; cctx->loadedDictEnd = 0; return 0;
|
||||||
default: return ERROR(parameter_unknown);
|
default: return ERROR(parameter_unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2323,7 +2323,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
|||||||
else cctx->nextToUpdate -= correction;
|
else cctx->nextToUpdate -= correction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((U32)(ip+blockSize - cctx->base) > (cctx->forceWindow ? 0 : cctx->loadedDictEnd) + maxDist) {
|
if ((U32)(ip+blockSize - cctx->base) > cctx->loadedDictEnd + maxDist) {
|
||||||
/* enforce maxDist */
|
/* enforce maxDist */
|
||||||
U32 const newLowLimit = (U32)(ip+blockSize - cctx->base) - maxDist;
|
U32 const newLowLimit = (U32)(ip+blockSize - cctx->base) - maxDist;
|
||||||
if (cctx->lowLimit < newLowLimit) cctx->lowLimit = newLowLimit;
|
if (cctx->lowLimit < newLowLimit) cctx->lowLimit = newLowLimit;
|
||||||
@@ -2477,7 +2477,7 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_CCtx* zc, const void* src, size_t
|
|||||||
zc->dictBase = zc->base;
|
zc->dictBase = zc->base;
|
||||||
zc->base += ip - zc->nextSrc;
|
zc->base += ip - zc->nextSrc;
|
||||||
zc->nextToUpdate = zc->dictLimit;
|
zc->nextToUpdate = zc->dictLimit;
|
||||||
zc->loadedDictEnd = (U32)(iend - zc->base);
|
zc->loadedDictEnd = zc->forceWindow ? 0 : (U32)(iend - zc->base);
|
||||||
|
|
||||||
zc->nextSrc = iend;
|
zc->nextSrc = iend;
|
||||||
if (srcSize <= HASH_READ_SIZE) return 0;
|
if (srcSize <= HASH_READ_SIZE) return 0;
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, const void* d
|
|||||||
|
|
||||||
/* ZSDTMT_parameter :
|
/* ZSDTMT_parameter :
|
||||||
* List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
|
* List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
|
||||||
typedef enum { ZSTDMT_p_sectionSize /* size of input "section". Each section is compressed in parallel. 0 means default, which is dynamically determined within compression functions */
|
typedef enum {
|
||||||
|
ZSTDMT_p_sectionSize /* size of input "section". Each section is compressed in parallel. 0 means default, which is dynamically determined within compression functions */
|
||||||
} ZSDTMT_parameter;
|
} ZSDTMT_parameter;
|
||||||
|
|
||||||
/* ZSTDMT_setMTCtxParameter() :
|
/* ZSTDMT_setMTCtxParameter() :
|
||||||
|
|||||||
+3
-1
@@ -404,7 +404,9 @@ ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
|
|||||||
/*! ZSTD_setCCtxParameter() :
|
/*! ZSTD_setCCtxParameter() :
|
||||||
* Set advanced parameters, selected through enum ZSTD_CCtxParameter
|
* Set advanced parameters, selected through enum ZSTD_CCtxParameter
|
||||||
* @result : 0, or an error code (which can be tested with ZSTD_isError()) */
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()) */
|
||||||
typedef enum { ZSTD_p_forceWindow } ZSTD_CCtxParameter;
|
typedef enum {
|
||||||
|
ZSTD_p_forceWindow /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0)*/
|
||||||
|
} ZSTD_CCtxParameter;
|
||||||
size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value);
|
size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value);
|
||||||
|
|
||||||
/*! ZSTD_createCDict_byReference() :
|
/*! ZSTD_createCDict_byReference() :
|
||||||
|
|||||||
@@ -755,6 +755,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, U32 const maxD
|
|||||||
CHECK (ZSTD_isError(errorCode), "ZSTD_copyCCtx error : %s", ZSTD_getErrorName(errorCode));
|
CHECK (ZSTD_isError(errorCode), "ZSTD_copyCCtx error : %s", ZSTD_getErrorName(errorCode));
|
||||||
} }
|
} }
|
||||||
XXH64_reset(&xxhState, 0);
|
XXH64_reset(&xxhState, 0);
|
||||||
|
ZSTD_setCCtxParameter(ctx, ZSTD_p_forceWindow, FUZ_rand(&lseed) & 1);
|
||||||
{ U32 const nbChunks = (FUZ_rand(&lseed) & 127) + 2;
|
{ U32 const nbChunks = (FUZ_rand(&lseed) & 127) + 2;
|
||||||
U32 n;
|
U32 n;
|
||||||
for (totalTestSize=0, cSize=0, n=0 ; n<nbChunks ; n++) {
|
for (totalTestSize=0, cSize=0, n=0 ; n<nbChunks ; n++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user