]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
merge dedicated dParam setters
authorYann Collet <cyan@fb.com>
Wed, 5 Dec 2018 01:06:48 +0000 (17:06 -0800)
committerYann Collet <cyan@fb.com>
Wed, 5 Dec 2018 01:06:48 +0000 (17:06 -0800)
lib/decompress/zstd_decompress.c
tests/fuzzer.c

index c4cd66c845b27f9a7100fa8531aa7ac13e7b2561..d0b6063d155bddba207e3665ccf0360157d2bef5 100644 (file)
@@ -1241,19 +1241,24 @@ size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
     return 0;
 }
 
+/* ZSTD_DCtx_setMaxWindowSize() :
+ * note : no direct equivalence in ZSTD_DCtx_setParameter,
+ * since this version sets windowSize, and the other sets windowLog */
 size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize)
 {
+    ZSTD_bounds const bounds = ZSTD_dParam_getBounds(ZSTD_d_windowLogMax);
+    size_t const min = (size_t)1 << bounds.lowerBound;
+    size_t const max = (size_t)1 << bounds.upperBound;
     if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+    if (maxWindowSize < min) return ERROR(parameter_outOfBound);
+    if (maxWindowSize > max) return ERROR(parameter_outOfBound);
     dctx->maxWindowSize = maxWindowSize;
     return 0;
 }
 
 size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
 {
-    DEBUGLOG(4, "ZSTD_DCtx_setFormat : %u", (unsigned)format);
-    if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
-    dctx->format = format;
-    return 0;
+    return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format);
 }
 
 ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
index 67be1aa13b3fdd7c16ff2198d21ae36527477ff6..d3eef32adf30019ef2f3de861f1003a129bb82ef 100644 (file)
@@ -1393,7 +1393,7 @@ static int basicUnitTests(U32 seed, double compressibility)
 
         DISPLAYLEVEL(3, "test%3i : decompress of magic-less frame : ", testNb++);
         ZSTD_DCtx_reset(dctx, ZSTD_reset_session_and_parameters);
-        CHECK( ZSTD_DCtx_setFormat(dctx, ZSTD_f_zstd1_magicless) );
+        CHECK( ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, ZSTD_f_zstd1_magicless) );
         {   ZSTD_frameHeader zfh;
             size_t const zfhrt = ZSTD_getFrameHeader_advanced(&zfh, compressedBuffer, cSize, ZSTD_f_zstd1_magicless);
             if (zfhrt != 0) goto _output_error;