DORMANTno replies

[PATCH 2/5] Use new decompress helpers in diff.c

From: Marco Costalba <hidden>
Date: 2016-06-15 22:44:04
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Marco Costalba <redacted>
---
 diff.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/diff.c b/diff.c
index b18c140..ecfa721 100644
--- a/diff.c
+++ b/diff.c
@@ -2,6 +2,7 @@
  * Copyright (C) 2005 Junio C Hamano
  */
 #include "cache.h"
+#include "compress.h"
 #include "quote.h"
 #include "diff.h"
 #include "diffcore.h"
@@ -1037,23 +1038,10 @@ static unsigned char *deflate_it(char *data,
 				 unsigned long size,
 				 unsigned long *result_size)
 {
-	int bound;
-	unsigned char *deflated;
-	z_stream stream;
-
-	memset(&stream, 0, sizeof(stream));
-	deflateInit(&stream, zlib_compression_level);
-	bound = deflateBound(&stream, size);
-	deflated = xmalloc(bound);
-	stream.next_out = deflated;
-	stream.avail_out = bound;
-
-	stream.next_in = (unsigned char *)data;
-	stream.avail_in = size;
-	while (deflate(&stream, Z_FINISH) == Z_OK)
-		; /* nothing */
-	deflateEnd(&stream);
-	*result_size = stream.total_out;
+	unsigned char *deflated = NULL;
+
+	*result_size = z_deflate_all(zlib_compression_level,
+                                    (unsigned char *)data, size, &deflated);
 	return deflated;
 }
-- 
1.5.4.rc2.89.g1b3f
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help