Use int for srcSizeHint when sensible

This commit is contained in:
Nick Magerko 2019-08-19 16:49:25 -07:00
parent f9af70ca8a
commit 2d39b43906
2 changed files with 4 additions and 3 deletions

View File

@ -203,7 +203,7 @@ struct ZSTD_CCtx_params_s {
size_t targetCBlockSize; /* Tries to fit compressed block size to be around targetCBlockSize.
* No target when targetCBlockSize == 0.
* There is no guarantee on compressed block size */
size_t srcSizeHint; /* User's best guess of source size.
int srcSizeHint; /* User's best guess of source size.
* Hint is not valid when srcSizeHint == 0.
* There is no guarantee that hint is close to actual source size */

View File

@ -30,6 +30,7 @@
#include <string.h> /* strcmp, strlen */
#include <assert.h>
#include <errno.h> /* errno */
#include <limits.h> /* INT_MAX */
#include <signal.h>
#include "timefn.h" /* UTIL_getTime, UTIL_clockSpanMicro */
@ -305,7 +306,7 @@ struct FIO_prefs_s {
int ldmBucketSizeLog;
int ldmHashRateLog;
size_t targetCBlockSize;
size_t srcSizeHint;
int srcSizeHint;
ZSTD_literalCompressionMode_e literalCompressionMode;
/* IO preferences */
@ -425,7 +426,7 @@ void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize)
}
void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint) {
prefs->srcSizeHint = srcSizeHint;
prefs->srcSizeHint = (int)MIN((size_t)INT_MAX, srcSizeHint);
}
void FIO_setLiteralCompressionMode(