]> git.ipfire.org Git - thirdparty/git.git/commitdiff
compat/zlib: provide `deflateBound()` shim centrally
authorPatrick Steinhardt <ps@pks.im>
Tue, 28 Jan 2025 08:41:31 +0000 (09:41 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jan 2025 21:03:22 +0000 (13:03 -0800)
The `deflateBound()` function has only been introduced with zlib 1.2.0.
When linking against a zlib version older than that we thus provide our
own compatibility shim. Move this shim into "compat/zlib.h" so that we
can adapt it based on whether or not we use zlib-ng in a subsequent
commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/zlib-compat.h
git-zlib.c

index bc20b884efab72028d5f696923e9800e39b08ce3..96a08811a98ff7fa057f5682a5303a06cef40cd1 100644 (file)
@@ -3,4 +3,8 @@
 
 #include <zlib.h>
 
+#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
+# define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
+#endif
+
 #endif /* COMPAT_ZLIB_H */
index d43bbeb6daa4c195048f7012e0bccff8c5b4b5f1..2e973320c232438cce7c83e25cc60a6b773670fc 100644 (file)
@@ -147,10 +147,6 @@ int git_inflate(git_zstream *strm, int flush)
        return status;
 }
 
-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
-#define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
-#endif
-
 unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
 {
        return deflateBound(&strm->z, size);