Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
index-pack.c | 20 +++-----------------
1 files changed, 3 insertions(+), 17 deletions(-)
Show changes to index-pack.c +3 −17
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