15 #include "compressionzlib.h"
30 m_zinflate.zalloc = Z_NULL;
31 m_zinflate.zfree = Z_NULL;
32 m_zinflate.opaque = Z_NULL;
33 m_zinflate.avail_in = 0;
34 m_zinflate.next_in = Z_NULL;
35 ret = inflateInit( &m_zinflate );
39 m_zdeflate.zalloc = Z_NULL;
40 m_zdeflate.zfree = Z_NULL;
41 m_zdeflate.opaque = Z_NULL;
42 m_zinflate.avail_in = 0;
43 m_zinflate.next_in = Z_NULL;
44 ret = deflateInit( &m_zdeflate, Z_BEST_COMPRESSION );
65 long unsigned int CHUNK = data.length() + ( data.length() / 100 ) + 13;
66 Bytef* out =
new Bytef[CHUNK];
67 char* in =
const_cast<char*
>( data.c_str() );
69 m_compressMutex.
lock();
71 m_zdeflate.avail_in =
static_cast<uInt
>( data.length() );
72 m_zdeflate.next_in = (Bytef*)in;
77 m_zdeflate.avail_out =
static_cast<uInt
>( CHUNK );
78 m_zdeflate.next_out = (Bytef*)out;
80 ret = deflate( &m_zdeflate, Z_SYNC_FLUSH );
81 result.append( (
char*)out, CHUNK - m_zdeflate.avail_out );
82 }
while( m_zdeflate.avail_out == 0 );
100 char* out =
new char[CHUNK];
101 char* in =
const_cast<char*
>( data.c_str() );
103 m_zinflate.avail_in =
static_cast<uInt
>( data.length() );
104 m_zinflate.next_in = (Bytef*)in;
110 m_zinflate.avail_out = CHUNK;
111 m_zinflate.next_out = (Bytef*)out;
113 ret = inflate( &m_zinflate, Z_SYNC_FLUSH );
114 result.append( out, CHUNK - m_zinflate.avail_out );
115 }
while( m_zinflate.avail_out == 0 );
127 inflateEnd( &m_zinflate );
128 deflateEnd( &m_zdeflate );