summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 776ea37)
raw | patch | inline | side by side (parent: 776ea37)
author | Nicolas Pitre <nico@fluxnic.net> | |
Mon, 12 Apr 2010 16:12:06 +0000 (12:12 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Apr 2010 16:51:42 +0000 (09:51 -0700) |
Rework the loop to remove duplicated calls to use() and fill(), and
to make the code easier to read.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to make the code easier to read.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-index-pack.c | patch | blob | history |
diff --git a/builtin-index-pack.c b/builtin-index-pack.c
index 127e713ddec575ee15e4ff052711ef2121799a64..4308abb60e8cf750f3c3a38c2100f910b0bcbdf9 100644 (file)
--- a/builtin-index-pack.c
+++ b/builtin-index-pack.c
static void *unpack_entry_data(unsigned long offset, unsigned long size)
{
+ int status;
z_stream stream;
void *buf = xmalloc(size);
memset(&stream, 0, sizeof(stream));
+ git_inflate_init(&stream);
stream.next_out = buf;
stream.avail_out = size;
- stream.next_in = fill(1);
- stream.avail_in = input_len;
- git_inflate_init(&stream);
- for (;;) {
- int ret = git_inflate(&stream, 0);
- use(input_len - stream.avail_in);
- if (stream.total_out == size && ret == Z_STREAM_END)
- break;
- if (ret != Z_OK)
- bad_object(offset, "inflate returned %d", ret);
+ do {
stream.next_in = fill(1);
stream.avail_in = input_len;
- }
+ status = git_inflate(&stream, 0);
+ use(input_len - stream.avail_in);
+ } while (status == Z_OK);
+ if (stream.total_out != size || status != Z_STREAM_END)
+ bad_object(offset, "inflate returned %d", status);
git_inflate_end(&stream);
return buf;
}