git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/5] Use new decompress helpers in diff.c
@ 2008-01-10 21:06 Marco Costalba
  0 siblings, 0 replies; only message in thread
From: Marco Costalba @ 2008-01-10 21:06 UTC (permalink / raw)
  To: Git Mailing List

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-10 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-10 21:06 [PATCH 2/5] Use new decompress helpers in diff.c Marco Costalba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).