From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 5/6] zlib: wrap deflateBound() too
Date: Fri, 10 Jun 2011 13:15:47 -0700 [thread overview]
Message-ID: <1307736948-16956-6-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1307736948-16956-1-git-send-email-gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
archive-zip.c | 2 +-
builtin/pack-objects.c | 2 +-
cache.h | 4 +---
diff.c | 2 +-
fast-import.c | 4 ++--
http-push.c | 2 +-
remote-curl.c | 2 +-
zlib.c | 9 +++++++++
8 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/archive-zip.c b/archive-zip.c
index 081ff83..8fbac27 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -97,7 +97,7 @@ static void *zlib_deflate(void *data, unsigned long size,
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;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 61f9755..8981dd6 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -132,7 +132,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
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);
diff --git a/cache.h b/cache.h
index 5eb61ac..85ac5ec 100644
--- a/cache.h
+++ b/cache.h
@@ -16,9 +16,6 @@
#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);
@@ -30,6 +27,7 @@ void git_deflate_init_gzip(z_streamp strm, int level);
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)
diff --git a/diff.c b/diff.c
index c15c70f..bac9a4b 100644
--- a/diff.c
+++ b/diff.c
@@ -1733,7 +1733,7 @@ static unsigned char *deflate_it(char *data,
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;
diff --git a/fast-import.c b/fast-import.c
index 42979e6..e4116a4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1058,7 +1058,7 @@ static int store_object(
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 */
@@ -1081,7 +1081,7 @@ static int store_object(
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 */
diff --git a/http-push.c b/http-push.c
index 46e68c8..ecd67cf 100644
--- a/http-push.c
+++ b/http-push.c
@@ -360,7 +360,7 @@ static void start_put(struct transfer_request *request)
/* 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;
diff --git a/remote-curl.c b/remote-curl.c
index 3c7621a..13d8cee 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -476,7 +476,7 @@ static int post_rpc(struct rpc_state *rpc)
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;
diff --git a/zlib.c b/zlib.c
index ee47a3a..8f19d2f 100644
--- a/zlib.c
+++ b/zlib.c
@@ -78,6 +78,15 @@ int git_inflate(z_streamp 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(z_streamp strm, unsigned long size)
+{
+ return deflateBound(strm, size);
+}
+
void git_deflate_init(z_streamp strm, int level)
{
int status = deflateInit(strm, level);
--
1.7.6.rc1.118.ge175b4a
next prev parent reply other threads:[~2011-06-10 20:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-10 20:15 [PATCH 0/6] zlib only processes 4GB at a time Junio C Hamano
2011-06-10 20:15 ` [PATCH 1/6] zlib: refactor error message formatter Junio C Hamano
2011-06-10 20:15 ` [PATCH 2/6] zlib: wrap remaining calls to direct inflate/inflateEnd Junio C Hamano
2011-06-10 20:15 ` [PATCH 3/6] zlib: wrap inflateInit2 used to accept only for gzip format Junio C Hamano
2011-06-10 20:15 ` [PATCH 4/6] zlib: wrap deflate side of the API Junio C Hamano
2011-06-10 22:23 ` Thiago Farina
2011-06-10 23:00 ` Junio C Hamano
2011-06-10 20:15 ` Junio C Hamano [this message]
2011-06-10 20:15 ` [PATCH 6/6] zlib: zlib can only process 4GB at a time Junio C Hamano
2011-06-12 20:43 ` Erik Faye-Lund
2011-06-12 21:33 ` Junio C Hamano
2011-06-12 21:46 ` Matthieu Moy
2011-06-13 11:17 ` Erik Faye-Lund
2011-06-13 11:52 ` Jonathan Nieder
2011-06-13 11:56 ` Junio C Hamano
2011-06-10 23:47 ` [PATCH 7/6] zlib: allow feeding more than 4GB in one go Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1307736948-16956-6-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.