Thread (21 messages) flat view 21 messages, 3 authors, 2016-06-15

Re: [PATCH 08/11] Use new decompress_all() helper in git

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:10

Marco Costalba [off-list ref] writes:
quoted hunk ↗ jump to hunk
Only in two places is possible to really simplify
diff --git a/index-pack.c b/index-pack.c
index 880088e..30d7837 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -169,24 +169,18 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)
 	z_stream stream;
 	void *buf = xmalloc(size);
 
-	memset(&stream, 0, sizeof(stream));
-	stream.next_out = buf;
-	stream.avail_out = size;
-	stream.next_in = fill(1);
-	stream.avail_in = input_len;
-	inflateInit(&stream);
+	decompress_alloc(&stream);
+	decompress_into(&stream, buf, size);
 
 	for (;;) {
-		int ret = inflate(&stream, 0);
+		int ret = decompress_next_from(&stream, fill(1), input_len, Z_NO_FLUSH);
The input_len variable is changed as a side effect of calling
the fill() function.  Don't you have the same issue that you
handle with [10/11] here?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help