MCPcopy Index your code
hub / github.com/RsyncProject/rsync / deflateInit2_

Function deflateInit2_

zlib/deflate.c:212–348  ·  view source on GitHub ↗

========================================================================= */

Source from the content-addressed store, hash-verified

210
211/* ========================================================================= */
212int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits,
213 int memLevel, int strategy, const char *version, int stream_size)
214{
215 deflate_state *s;
216 int wrap = 1;
217 static const char my_version[] = ZLIB_VERSION;
218
219 if (version == Z_NULL || version[0] != my_version[0] ||
220 stream_size != sizeof(z_stream)) {
221 return Z_VERSION_ERROR;
222 }
223 if (strm == Z_NULL) return Z_STREAM_ERROR;
224
225 strm->msg = Z_NULL;
226 if (strm->zalloc == (alloc_func)0) {
227#ifdef Z_SOLO
228 return Z_STREAM_ERROR;
229#else
230 strm->zalloc = zcalloc;
231 strm->opaque = (voidpf)0;
232#endif
233 }
234 if (strm->zfree == (free_func)0)
235#ifdef Z_SOLO
236 return Z_STREAM_ERROR;
237#else
238 strm->zfree = zcfree;
239#endif
240
241#ifdef FASTEST
242 if (level != 0) level = 1;
243#else
244 if (level == Z_DEFAULT_COMPRESSION) level = 6;
245#endif
246
247 if (windowBits < 0) { /* suppress zlib wrapper */
248 wrap = 0;
249 windowBits = -windowBits;
250 }
251#ifdef GZIP
252 else if (windowBits > 15) {
253 wrap = 2; /* write gzip wrapper instead */
254 windowBits -= 16;
255 }
256#endif
257 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
258 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
259 strategy < 0 || strategy > Z_FIXED) {
260 return Z_STREAM_ERROR;
261 }
262 if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
263 s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
264 if (s == Z_NULL) return Z_MEM_ERROR;
265 strm->state = (struct internal_state FAR *)s;
266 s->strm = strm;
267
268 s->wrap = wrap;
269 s->gzhead = Z_NULL;

Callers 1

deflateInit_Function · 0.85

Calls 2

deflateEndFunction · 0.85
deflateResetFunction · 0.85

Tested by

no test coverage detected