{"thread":{"id":"11568","subject":"[PATCH 2/5] Use new decompress helpers in diff.c","startedAt":"2008-01-10T21:06:16Z","lastAt":"2008-01-10T21:06:16Z","messageCount":1,"participants":["Marco Costalba"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"64947","messageId":"e5bfff550801101306i4e62e339tb9e86414c3e7894e@mail.gmail.com","threadId":"11568","inReplyTo":null,"subject":"[PATCH 2/5] Use new decompress helpers in diff.c","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2008-01-10T21:06:16Z","receivedAt":"2008-01-10T21:06:16Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"Signed-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n diff.c |   22 +++++-----------------\n 1 files changed, 5 insertions(+), 17 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b18c140..ecfa721 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2,6 +2,7 @@\n  * Copyright (C) 2005 Junio C Hamano\n  */\n #include \"cache.h\"\n+#include \"compress.h\"\n #include \"quote.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n@@ -1037,23 +1038,10 @@ static unsigned char *deflate_it(char *data,\n \t\t\t\t unsigned long size,\n \t\t\t\t unsigned long *result_size)\n {\n-\tint bound;\n-\tunsigned char *deflated;\n-\tz_stream stream;\n-\n-\tmemset(&stream, 0, sizeof(stream));\n-\tdeflateInit(&stream, zlib_compression_level);\n-\tbound = deflateBound(&stream, size);\n-\tdeflated = xmalloc(bound);\n-\tstream.next_out = deflated;\n-\tstream.avail_out = bound;\n-\n-\tstream.next_in = (unsigned char *)data;\n-\tstream.avail_in = size;\n-\twhile (deflate(&stream, Z_FINISH) == Z_OK)\n-\t\t; /* nothing */\n-\tdeflateEnd(&stream);\n-\t*result_size = stream.total_out;\n+\tunsigned char *deflated = NULL;\n+\n+\t*result_size = z_deflate_all(zlib_compression_level,\n+                                    (unsigned char *)data, size, &deflated);\n \treturn deflated;\n }\n\n-- \n1.5.4.rc2.89.g1b3f\n"}]}