aboutsummaryrefslogtreecommitdiff
path: root/dep/src/zlib/compress.c
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:51:44 -0700
committermaximius <none@none>2009-10-17 15:51:44 -0700
commite585187b248f48b3c6e9247b49fa07c6565d65e5 (patch)
tree637c5b7ddacf41040bef4ea4f75a97da64c6a9bc /dep/src/zlib/compress.c
parent26b5e033ffde3d161382fc9addbfa99738379641 (diff)
*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
Diffstat (limited to 'dep/src/zlib/compress.c')
-rw-r--r--dep/src/zlib/compress.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/dep/src/zlib/compress.c b/dep/src/zlib/compress.c
index 488bfa6cda9..df04f0148e6 100644
--- a/dep/src/zlib/compress.c
+++ b/dep/src/zlib/compress.c
@@ -2,15 +2,19 @@
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
+
/* @(#) $Id$ */
+
#define ZLIB_INTERNAL
#include "zlib.h"
+
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
+
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
@@ -24,6 +28,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
{
z_stream stream;
int err;
+
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
@@ -33,20 +38,25 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
+
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
+
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
+
err = deflateEnd(&stream);
return err;
}
+
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
@@ -57,6 +67,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
+
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.