Merge branch 'jc/zlib-wrap' into maint

* jc/zlib-wrap:
  zlib: allow feeding more than 4GB in one go
  zlib: zlib can only process 4GB at a time
  zlib: wrap deflateBound() too
  zlib: wrap deflate side of the API
  zlib: wrap inflateInit2 used to accept only for gzip format
  zlib: wrap remaining calls to direct inflate/inflateEnd
  zlib wrapper: refactor error message formatter
This commit is contained in:
Junio C Hamano
2011-08-16 11:23:26 -07:00
15 changed files with 328 additions and 131 deletions

View File

@ -473,16 +473,12 @@ static int post_rpc(struct rpc_state *rpc)
* the transfer time.
*/
size_t size;
z_stream stream;
git_zstream stream;
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);
size = deflateBound(&stream, rpc->len);
git_deflate_init_gzip(&stream, Z_BEST_COMPRESSION);
size = git_deflate_bound(&stream, rpc->len);
gzip_body = xmalloc(size);
stream.next_in = (unsigned char *)rpc->buf;
@ -490,11 +486,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);