Re: [PATCH 08/11] Use new decompress_all() helper in git
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 4, 2008, 02:07 UTC
- Message-ID
- <7vve55mq31.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1201952156-6764-8-git-send-email-mcostalba@gmail.com>
Marco Costalba <mcostalba@gmail.com> writes:
Show 21 quoted lines
> 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?