memset(&stream, 0, sizeof(stream));
git_deflate_init(&stream, compression_level);
- maxsize = deflateBound(&stream, size);
+ maxsize = git_deflate_bound(&stream, size);
buffer = xmalloc(maxsize);
stream.next_in = data;
memset(&stream, 0, sizeof(stream));
git_deflate_init(&stream, pack_compression_level);
- maxsize = deflateBound(&stream, size);
+ maxsize = git_deflate_bound(&stream, size);
in = *pptr;
out = xmalloc(maxsize);
#endif
#include <zlib.h>
-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
-#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
-#endif
void git_inflate_init(z_streamp strm);
void git_inflate_init_gzip_only(z_streamp strm);
void git_deflate_end(z_streamp strm);
int git_deflate_end_gently(z_streamp strm);
int git_deflate(z_streamp strm, int flush);
+unsigned long git_deflate_bound(z_streamp, unsigned long);
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
memset(&stream, 0, sizeof(stream));
git_deflate_init(&stream, zlib_compression_level);
- bound = deflateBound(&stream, size);
+ bound = git_deflate_bound(&stream, size);
deflated = xmalloc(bound);
stream.next_out = deflated;
stream.avail_out = bound;
s.next_in = (void *)dat->buf;
s.avail_in = dat->len;
}
- s.avail_out = deflateBound(&s, s.avail_in);
+ s.avail_out = git_deflate_bound(&s, s.avail_in);
s.next_out = out = xmalloc(s.avail_out);
while (git_deflate(&s, Z_FINISH) == Z_OK)
; /* nothing */
git_deflate_init(&s, pack_compression_level);
s.next_in = (void *)dat->buf;
s.avail_in = dat->len;
- s.avail_out = deflateBound(&s, s.avail_in);
+ s.avail_out = git_deflate_bound(&s, s.avail_in);
s.next_out = out = xrealloc(out, s.avail_out);
while (git_deflate(&s, Z_FINISH) == Z_OK)
; /* nothing */
/* Set it up */
memset(&stream, 0, sizeof(stream));
git_deflate_init(&stream, zlib_compression_level);
- size = deflateBound(&stream, len + hdrlen);
+ size = git_deflate_bound(&stream, len + hdrlen);
strbuf_init(&request->buffer.buf, size);
request->buffer.posn = 0;
memset(&stream, 0, sizeof(stream));
git_deflate_init_gzip(&stream, Z_BEST_COMPRESSION);
- size = deflateBound(&stream, rpc->len);
+ size = git_deflate_bound(&stream, rpc->len);
gzip_body = xmalloc(size);
stream.next_in = (unsigned char *)rpc->buf;
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(z_streamp strm, unsigned long size)
+{
+ return deflateBound(strm, size);
+}
+
void git_deflate_init(z_streamp strm, int level)
{
int status = deflateInit(strm, level);