Rename zlibwrappre APIs to fellow UADK rules. And remove the useles input parameters.
Signed-off-by: Yang Shen shenyang39@huawei.com --- include/wd_zlibwrapper.h | 30 ++++++------------------------ wd_zlibwrapper.c | 32 +++++++++++--------------------- 2 files changed, 17 insertions(+), 45 deletions(-)
diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h index a409f36..847a315 100644 --- a/include/wd_zlibwrapper.h +++ b/include/wd_zlibwrapper.h @@ -16,8 +16,6 @@ extern "C" { #endif
-#define ZLIB_VERSION "1.2.11" - /* Allowed flush values; the same as zlib library */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 @@ -89,33 +87,17 @@ typedef struct z_stream_s {
typedef z_stream * z_streamp;
-int wd_deflateInit_(z_streamp strm, int level, const char *version, int stream_size); -int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, - int memLevel, int strategy, const char *version, int stream_size); +int wd_deflate_init(z_streamp strm, int level, int windowbits); /* * The flush support Z_SYNC_FLUSH and Z_FINISH only. */ int wd_deflate(z_streamp strm, int flush); -int wd_deflateReset(z_streamp strm); -int wd_deflateEnd(z_streamp strm); +int wd_deflate_reset(z_streamp strm); +int wd_deflate_end(z_streamp strm);
-int wd_inflateInit_(z_streamp strm, const char *version, int stream_size); -int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size); +int wd_inflate_init(z_streamp strm, int windowbits); int wd_inflate(z_streamp strm, int flush); -int wd_inflateReset(z_streamp strm); -int wd_inflateEnd(z_streamp strm); - -#define wd_deflateInit(strm, level) \ - wd_deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - wd_deflateInit2_((strm), (level), (method), (windowBits), (memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_inflateInit(strm) \ - wd_inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_inflateInit2(strm, windowBits) \ - wd_inflateInit2_((strm), (windowBits), ZLIB_VERSION, (int)sizeof(z_stream)) +int wd_inflate_reset(z_streamp strm); +int wd_inflate_end(z_streamp strm);
#endif /* UADK_ZLIBWRAPPER_H */ diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 46a5c75..86e92f7 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -257,19 +257,11 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty }
/* === Compression === */ -int wd_deflateInit_(z_streamp strm, int level, const char *version, int stream_size) - -{ - return wd_deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); -} - -int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, - int memLevel, int strategy, const char *version, int stream_size) +int wd_deflate_init(z_streamp strm, int level, int windowbits) { pthread_atfork(NULL, NULL, wd_zlib_unlock);
- return wd_zlib_init(strm, level, windowBits, WD_DIR_COMPRESS); + return wd_zlib_init(strm, level, windowbits, WD_DIR_COMPRESS); }
int wd_deflate(z_streamp strm, int flush) @@ -277,7 +269,7 @@ int wd_deflate(z_streamp strm, int flush) return wd_zlib_do_request(strm, flush, WD_DIR_COMPRESS); }
-int wd_deflateReset(z_streamp strm) +int wd_deflate_reset(z_streamp strm) { if (!strm) return Z_STREAM_ERROR; @@ -290,30 +282,28 @@ int wd_deflateReset(z_streamp strm) return Z_OK; }
-int wd_deflateEnd(z_streamp strm) +int wd_deflate_end(z_streamp strm) { return wd_zlib_uninit(strm); }
/* === Decompression === */ -int wd_inflateInit_(z_streamp strm, const char *version, int stream_size) -{ - return wd_inflateInit2_(strm, MAX_WBITS, version, stream_size); -} - -int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) +int wd_inflate_init(z_streamp strm, int windowbits) { pthread_atfork(NULL, NULL, wd_zlib_unlock);
- return wd_zlib_init(strm, 0, windowBits, WD_DIR_DECOMPRESS); + return wd_zlib_init(strm, 0, windowbits, WD_DIR_DECOMPRESS); }
int wd_inflate(z_streamp strm, int flush) { + if (unlikely(!strm)) + return Z_STREAM_ERROR; + return wd_zlib_do_request(strm, flush, WD_DIR_DECOMPRESS); }
-int wd_inflateReset(z_streamp strm) +int wd_inflate_reset(z_streamp strm) { if (!strm) return Z_STREAM_ERROR; @@ -326,7 +316,7 @@ int wd_inflateReset(z_streamp strm) return Z_OK; }
-int wd_inflateEnd(z_streamp strm) +int wd_inflate_end(z_streamp strm) { return wd_zlib_uninit(strm); }