Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
compress.cc File Reference
#include "zlib.h"

Go to the source code of this file.

Macros

#define ZLIB_INTERNAL
 

Functions

int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
 
int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
 
uLong ZEXPORT compressBound (uLong sourceLen)
 

Macro Definition Documentation

◆ ZLIB_INTERNAL

#define ZLIB_INTERNAL

Definition at line 8 of file compress.cc.

Function Documentation

◆ compress()

int ZEXPORT compress ( Bytef dest,
uLongf destLen,
const Bytef source,
uLong  sourceLen 
)

Definition at line 57 of file compress.cc.

58{
59 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
60}
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
Definition: compress.cc:22
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:163

Referenced by cheprep::XMLHepRepFactory::createHepRepWriter(), cheprep::DeflateOutputStreamBuffer::init(), cheprep::ZipOutputStream::putNextEntry(), and cheprep::ZipOutputStreamBuffer::putNextEntry().

◆ compress2()

int ZEXPORT compress2 ( Bytef dest,
uLongf destLen,
const Bytef source,
uLong  sourceLen,
int  level 
)

Definition at line 22 of file compress.cc.

23{
24 z_stream stream;
25 int err;
26
27 stream.next_in = (Bytef*)source;
28 stream.avail_in = (uInt)sourceLen;
29#ifdef MAXSEG_64K
30 /* Check for source > 64K on 16-bit machine: */
31 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
32#endif
33 stream.next_out = dest;
34 stream.avail_out = (uInt)*destLen;
35 if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
36
37 stream.zalloc = (alloc_func)0;
38 stream.zfree = (free_func)0;
39 stream.opaque = (voidpf)0;
40
41 err = deflateInit(&stream, level);
42 if (err != Z_OK) return err;
43
44 err = deflate(&stream, Z_FINISH);
45 if (err != Z_STREAM_END) {
46 deflateEnd(&stream);
47 return err == Z_OK ? Z_BUF_ERROR : err;
48 }
49 *destLen = stream.total_out;
50
51 err = deflateEnd(&stream);
52 return err;
53}
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.cc:670
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.cc:496
uInt avail_in
Definition: zlib.h:84
Bytef * next_in
Definition: zlib.h:83
alloc_func zalloc
Definition: zlib.h:94
uInt avail_out
Definition: zlib.h:88
free_func zfree
Definition: zlib.h:95
voidpf opaque
Definition: zlib.h:96
uLong total_out
Definition: zlib.h:89
Bytef * next_out
Definition: zlib.h:87
Byte FAR * voidpf
Definition: zconf.h:277
unsigned int uInt
Definition: zconf.h:257
unsigned long uLong
Definition: zconf.h:258
Byte FAR Bytef
Definition: zconf.h:264
#define Z_BUF_ERROR
Definition: zlib.h:154
#define Z_STREAM_END
Definition: zlib.h:148
#define Z_FINISH
Definition: zlib.h:143
#define Z_OK
Definition: zlib.h:147
#define deflateInit(strm, level)
Definition: zlib.h:1174

Referenced by compress().

◆ compressBound()

uLong ZEXPORT compressBound ( uLong  sourceLen)

Definition at line 66 of file compress.cc.

67{
68 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
69}

Referenced by deflateBound().