compat/zlib: provide `deflateBound()` shim centrally
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>
Patrick Steinhardt committed
Jan 28, 2025 at 09:41 UTC
a2dcb6999837c762b85735174eb16f941830a2e7
2 files changed
+4
-4
compat/zlib-compat.h
+4
@@ -3,4 +3,8 @@
3
4
#include <zlib.h>
5
6
+#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
7
+# define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
8
+#endif
9
+
10
#endif /* COMPAT_ZLIB_H */
git-zlib.c
-4
@@ -147,10 +147,6 @@ int git_inflate(git_zstream *strm, int flush)
147
return status;
148
}
149
150
-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
151
-#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
152
-#endif
153
-
150
unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
151
{
152
return deflateBound(&strm->z, size);