Skip to content

Commit

Permalink
compat/zlib: provide deflateBound() shim centrally
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pks-t authored and gitster committed Jan 28, 2025
1 parent 41f1a84 commit a2dcb69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions compat/zlib-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
4 changes: 0 additions & 4 deletions git-zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a2dcb69

Please sign in to comment.