diff --git a/zlibWrapper/README.md b/zlibWrapper/README.md index e86da2f58..e90a5189a 100644 --- a/zlibWrapper/README.md +++ b/zlibWrapper/README.md @@ -79,6 +79,7 @@ Supported methods: - inflate - inflateSetDictionary - inflateReset +- inflateReset2 - compress - compress2 - compressBound @@ -97,7 +98,6 @@ Unsupported methods: - inflateGetDictionary - inflateCopy - inflateSync -- inflateReset2 - inflatePrime - inflateMark - inflateGetHeader diff --git a/zlibWrapper/zstd_zlibwrapper.c b/zlibWrapper/zstd_zlibwrapper.c index 90ec590d0..d3f95fb9c 100644 --- a/zlibWrapper/zstd_zlibwrapper.c +++ b/zlibWrapper/zstd_zlibwrapper.c @@ -413,6 +413,7 @@ ZEXTERN int ZEXPORT z_inflateInit2_ OF((z_streamp strm, int windowBits, int ret = z_inflateInit_ (strm, version, stream_size); if (ret == Z_OK) { ZWRAP_DCtx* zwd = (ZWRAP_DCtx*)strm->state; + if (zwd == NULL) return Z_STREAM_ERROR; zwd->windowBits = windowBits; } return ret; @@ -438,6 +439,25 @@ ZEXTERN int ZEXPORT z_inflateReset OF((z_streamp strm)) } +#if ZLIB_VERNUM >= 0x1240 +ZEXTERN int ZEXPORT z_inflateReset2 OF((z_streamp strm, + int windowBits)) +{ + if (!strm->reserved) + return inflateReset2(strm, windowBits); + + { int ret = z_inflateReset (strm); + if (ret == Z_OK) { + ZWRAP_DCtx* zwd = (ZWRAP_DCtx*)strm->state; + if (zwd == NULL) return Z_STREAM_ERROR; + zwd->windowBits = windowBits; + } + return ret; + } +} +#endif + + ZEXTERN int ZEXPORT z_inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)) @@ -717,17 +737,6 @@ ZEXTERN int ZEXPORT z_inflateCopy OF((z_streamp dest, } -#if ZLIB_VERNUM >= 0x1240 -ZEXTERN int ZEXPORT z_inflateReset2 OF((z_streamp strm, - int windowBits)) -{ - if (!strm->reserved) - return inflateReset2(strm, windowBits); - FINISH_WITH_ERR(strm, "inflateReset2 is not supported!"); -} -#endif - - #if ZLIB_VERNUM >= 0x1240 ZEXTERN long ZEXPORT z_inflateMark OF((z_streamp strm)) {