compress.c (e37bb444aa945ed0725766e986698a09bd61b1b2) compress.c (4717628ed859513a3262ea68259d0605f39de0b3)
1/* compress.c -- compress a memory buffer
2 * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6/* @(#) $Id$ */
7
8#define ZLIB_INTERNAL

--- 5 unchanged lines hidden (view full) ---

14 length of the source buffer. Upon entry, destLen is the total size of the
15 destination buffer, which must be at least 0.1% larger than sourceLen plus
16 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
17
18 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
19 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
20 Z_STREAM_ERROR if the level parameter is invalid.
21*/
1/* compress.c -- compress a memory buffer
2 * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6/* @(#) $Id$ */
7
8#define ZLIB_INTERNAL

--- 5 unchanged lines hidden (view full) ---

14 length of the source buffer. Upon entry, destLen is the total size of the
15 destination buffer, which must be at least 0.1% larger than sourceLen plus
16 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
17
18 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
19 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
20 Z_STREAM_ERROR if the level parameter is invalid.
21*/
22int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
23 Bytef *dest;
24 uLongf *destLen;
25 const Bytef *source;
26 uLong sourceLen;
27 int level;
28{
22int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
23 uLong sourceLen, int level) {
29 z_stream stream;
30 int err;
31 const uInt max = (uInt)-1;
32 uLong left;
33
34 left = *destLen;
35 *destLen = 0;
36

--- 23 unchanged lines hidden (view full) ---

60
61 *destLen = stream.total_out;
62 deflateEnd(&stream);
63 return err == Z_STREAM_END ? Z_OK : err;
64}
65
66/* ===========================================================================
67 */
24 z_stream stream;
25 int err;
26 const uInt max = (uInt)-1;
27 uLong left;
28
29 left = *destLen;
30 *destLen = 0;
31

--- 23 unchanged lines hidden (view full) ---

55
56 *destLen = stream.total_out;
57 deflateEnd(&stream);
58 return err == Z_STREAM_END ? Z_OK : err;
59}
60
61/* ===========================================================================
62 */
68int ZEXPORT compress(dest, destLen, source, sourceLen)
69 Bytef *dest;
70 uLongf *destLen;
71 const Bytef *source;
72 uLong sourceLen;
73{
63int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
64 uLong sourceLen) {
74 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
75}
76
77/* ===========================================================================
78 If the default memLevel or windowBits for deflateInit() is changed, then
79 this function needs to be updated.
80 */
65 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
66}
67
68/* ===========================================================================
69 If the default memLevel or windowBits for deflateInit() is changed, then
70 this function needs to be updated.
71 */
81uLong ZEXPORT compressBound(sourceLen)
82 uLong sourceLen;
83{
72uLong ZEXPORT compressBound(uLong sourceLen) {
84 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
85 (sourceLen >> 25) + 13;
86}
73 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
74 (sourceLen >> 25) + 13;
75}