Skip to content

Commit a2dcb69

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 41f1a84 commit a2dcb69

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compat/zlib-compat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33

44
#include <zlib.h>
55

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+
610
#endif /* COMPAT_ZLIB_H */

git-zlib.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ int git_inflate(git_zstream *strm, int flush)
147147
return status;
148148
}
149149

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-
154150
unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
155151
{
156152
return deflateBound(&strm->z, size);

0 commit comments

Comments
 (0)