aboutsummaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-10 10:55:10 -0700
committerJunio C Hamano <gitster@pobox.com>2011-06-10 11:10:29 -0700
commit55bb5c9147a209eba44c3e9866704ece424c3d31 (patch)
tree1b3561115345d0b236085d741da75390cb1e759b /remote-curl.c
parent5e86c1fb866ca4bc8d6e015ccbdafd114fd616fa (diff)
downloadgit-55bb5c9147a209eba44c3e9866704ece424c3d31.tar.gz
git-55bb5c9147a209eba44c3e9866704ece424c3d31.tar.xz
zlib: wrap deflate side of the API
Wrap deflateInit, deflate, and deflateEnd for everybody, and the sole use of deflateInit2 in remote-curl.c to tell the library to use gzip header and trailer in git_deflate_init_gzip(). There is only one caller that cares about the status from deflateEnd(). Introduce git_deflate_end_gently() to let that sole caller retrieve the status and act on it (i.e. die) for now, but we would probably want to make inflate_end/deflate_end die when they ran out of memory and get rid of the _gently() kind. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 775d61430..3c7621aa0 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -475,11 +475,7 @@ static int post_rpc(struct rpc_state *rpc)
int ret;
memset(&stream, 0, sizeof(stream));
- ret = deflateInit2(&stream, Z_BEST_COMPRESSION,
- Z_DEFLATED, (15 + 16),
- 8, Z_DEFAULT_STRATEGY);
- if (ret != Z_OK)
- die("cannot deflate request; zlib init error %d", ret);
+ git_deflate_init_gzip(&stream, Z_BEST_COMPRESSION);
size = deflateBound(&stream, rpc->len);
gzip_body = xmalloc(size);
@@ -488,11 +484,11 @@ static int post_rpc(struct rpc_state *rpc)
stream.next_out = (unsigned char *)gzip_body;
stream.avail_out = size;
- ret = deflate(&stream, Z_FINISH);
+ ret = git_deflate(&stream, Z_FINISH);
if (ret != Z_STREAM_END)
die("cannot deflate request; zlib deflate error %d", ret);
- ret = deflateEnd(&stream);
+ ret = git_deflate_end_gently(&stream);
if (ret != Z_OK)
die("cannot deflate request; zlib end error %d", ret);