{"thread":{"id":"11569","subject":"[PATCH 3/5] Use new decompress helpers in index-pack.c","startedAt":"2008-01-10T21:07:24Z","lastAt":"2008-01-10T21:07:24Z","messageCount":1,"participants":["Marco Costalba"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"64948","messageId":"e5bfff550801101307g1675b94an46c25d9de03d2b46@mail.gmail.com","threadId":"11569","inReplyTo":null,"subject":"[PATCH 3/5] Use new decompress helpers in index-pack.c","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2008-01-10T21:07:24Z","receivedAt":"2008-01-10T21:07:24Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"Signed-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n index-pack.c |   20 +++-----------------\n 1 files changed, 3 insertions(+), 17 deletions(-)\n\ndiff --git a/index-pack.c b/index-pack.c\nindex 9fd6982..3c4ea51 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"compress.h\"\n #include \"delta.h\"\n #include \"pack.h\"\n #include \"csum-file.h\"\n@@ -494,24 +495,9 @@ static void parse_pack_objects(unsigned char *sha1)\n\n static int write_compressed(int fd, void *in, unsigned int size,\nuint32_t *obj_crc)\n {\n-\tz_stream stream;\n-\tunsigned long maxsize;\n-\tvoid *out;\n+\tunsigned char *out = NULL;\n\n-\tmemset(&stream, 0, sizeof(stream));\n-\tdeflateInit(&stream, zlib_compression_level);\n-\tmaxsize = deflateBound(&stream, size);\n-\tout = xmalloc(maxsize);\n-\n-\t/* Compress it */\n-\tstream.next_in = in;\n-\tstream.avail_in = size;\n-\tstream.next_out = out;\n-\tstream.avail_out = maxsize;\n-\twhile (deflate(&stream, Z_FINISH) == Z_OK);\n-\tdeflateEnd(&stream);\n-\n-\tsize = stream.total_out;\n+\tsize = z_deflate_all(zlib_compression_level, in, size, &out);\n \twrite_or_die(fd, out, size);\n \t*obj_crc = crc32(*obj_crc, out, size);\n \tfree(out);\n-- \n1.5.4.rc2.89.g1b3f\n"}]}