From e449cbcc37af03e5ed1942f3a49edd4df39075bc Mon Sep 17 00:00:00 2001 From: Kornel Date: Thu, 12 Oct 2023 16:36:09 +0100 Subject: [PATCH] Small fixes --- .gitignore | 1 + adler32.c | 14 +++++++------- compress.c | 2 +- examples/gzlog.c | 2 ++ gzguts.h | 4 ++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 4b8edc043..860ac9829 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ /minigzipsh /zlib.pc /zconf.h.included +/configure.log .DS_Store diff --git a/adler32.c b/adler32.c index 5b02d214f..b1567908c 100644 --- a/adler32.c +++ b/adler32.c @@ -7,10 +7,6 @@ #include "zutil.h" -#define local static - -local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); - #define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -66,8 +62,7 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); #endif /* ========================================================================= */ -uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) -{ +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { unsigned long sum2; unsigned n; @@ -139,7 +134,12 @@ uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) } /* ========================================================================= */ -static uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { + return adler32_z(adler, buf, len); +} + +/* ========================================================================= */ +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { unsigned long sum1; unsigned long sum2; unsigned rem; diff --git a/compress.c b/compress.c index 2429fb2bb..f43bacf7a 100644 --- a/compress.c +++ b/compress.c @@ -23,7 +23,7 @@ int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level) { z_stream stream; int err; - const uInt max = -1; + const uInt max = (uInt)-1; uLong left; left = *destLen; diff --git a/examples/gzlog.c b/examples/gzlog.c index d558777e2..b977802dd 100644 --- a/examples/gzlog.c +++ b/examples/gzlog.c @@ -756,12 +756,14 @@ local int log_recover(struct log *log, int op) return -2; } if ((fd = open(log->path, O_RDONLY, 0)) < 0) { + free(data); log_log(log, op, ".add file read failure"); return -1; } ret = (size_t)read(fd, data, len) != len; close(fd); if (ret) { + free(data); log_log(log, op, ".add file read failure"); return -1; } diff --git a/gzguts.h b/gzguts.h index 9a6425b4f..f9375047e 100644 --- a/gzguts.h +++ b/gzguts.h @@ -38,6 +38,10 @@ # include #endif +#if defined(_WIN32) +# define WIDECHAR +#endif + #ifdef WINAPI_FAMILY # define open _open # define read _read