summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-10 18:52:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-06-10 18:52:15 (GMT)
commitef49a7a0126d64359c974b4b3b71d7ad42ee3bca (patch)
tree2e9b67a18c4c37802cd7459ff7f3fb9bff4508c3 /fast-import.c
parent225a6f1068f71723a910e8565db4e252b3ca21fa (diff)
downloadgit-ef49a7a0126d64359c974b4b3b71d7ad42ee3bca.zip
git-ef49a7a0126d64359c974b4b3b71d7ad42ee3bca.tar.gz
git-ef49a7a0126d64359c974b4b3b71d7ad42ee3bca.tar.bz2
zlib: zlib can only process 4GB at a time
The size of objects we read from the repository and data we try to put into the repository are represented in "unsigned long", so that on larger architectures we can handle objects that weigh more than 4GB. But the interface defined in zlib.h to communicate with inflate/deflate limits avail_in (how many bytes of input are we calling zlib with) and avail_out (how many bytes of output from zlib are we ready to accept) fields effectively to 4GB by defining their type to be uInt. In many places in our code, we allocate a large buffer (e.g. mmap'ing a large loose object file) and tell zlib its size by assigning the size to avail_in field of the stream, but that will truncate the high octets of the real size. The worst part of this story is that we often pass around z_stream (the state object used by zlib) to keep track of the number of used bytes in input/output buffer by inspecting these two fields, which practically limits our callchain to the same 4GB limit. Wrap z_stream in another structure git_zstream that can express avail_in and avail_out in unsigned long. For now, just die() when the caller gives a size that cannot be given to a single zlib call. In later patches in the series, we would make git_inflate() and git_deflate() internally loop to give callers an illusion that our "improved" version of zlib interface can operate on a buffer larger than 4GB in one go. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fast-import.c b/fast-import.c
index e4116a4..1d5e333 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1017,7 +1017,7 @@ static int store_object(
unsigned char sha1[20];
unsigned long hdrlen, deltalen;
git_SHA_CTX c;
- z_stream s;
+ git_zstream s;
hdrlen = sprintf((char *)hdr,"%s %lu", typename(type),
(unsigned long)dat->len) + 1;
@@ -1163,7 +1163,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
off_t offset;
git_SHA_CTX c;
git_SHA_CTX pack_file_ctx;
- z_stream s;
+ git_zstream s;
int status = Z_OK;
/* Determine if we should auto-checkpoint. */