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

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 index-pack.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/index-pack.c b/index-pack.c
index 9fd6982..3c4ea51 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "compress.h"
 #include "delta.h"
 #include "pack.h"
 #include "csum-file.h"
@@ -494,24 +495,9 @@ static void parse_pack_objects(unsigned char *sha1)

 static int write_compressed(int fd, void *in, unsigned int size,
uint32_t *obj_crc)
 {
-	z_stream stream;
-	unsigned long maxsize;
-	void *out;
+	unsigned char *out = NULL;

-	memset(&stream, 0, sizeof(stream));
-	deflateInit(&stream, zlib_compression_level);
-	maxsize = deflateBound(&stream, size);
-	out = xmalloc(maxsize);
-
-	/* Compress it */
-	stream.next_in = in;
-	stream.avail_in = size;
-	stream.next_out = out;
-	stream.avail_out = maxsize;
-	while (deflate(&stream, Z_FINISH) == Z_OK);
-	deflateEnd(&stream);
-
-	size = stream.total_out;
+	size = z_deflate_all(zlib_compression_level, in, size, &out);
 	write_or_die(fd, out, size);
 	*obj_crc = crc32(*obj_crc, out, size);
 	free(out);
-- 
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:07 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:07 [PATCH 3/5] Use new decompress helpers in index-pack.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).