MCPcopy Create free account
hub / github.com/MariaDB/server / deflateInit2_

Function deflateInit2_

zlib/deflate.c:387–533  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

385
386/* ========================================================================= */
387int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
388 int windowBits, int memLevel, int strategy,
389 const char *version, int stream_size) {
390 deflate_state *s;
391 int wrap = 1;
392 static const char my_version[] = ZLIB_VERSION;
393
394 if (version == Z_NULL || version[0] != my_version[0] ||
395 stream_size != sizeof(z_stream)) {
396 return Z_VERSION_ERROR;
397 }
398 if (strm == Z_NULL) return Z_STREAM_ERROR;
399
400 strm->msg = Z_NULL;
401 if (strm->zalloc == (alloc_func)0) {
402#ifdef Z_SOLO
403 return Z_STREAM_ERROR;
404#else
405 strm->zalloc = zcalloc;
406 strm->opaque = (voidpf)0;
407#endif
408 }
409 if (strm->zfree == (free_func)0)
410#ifdef Z_SOLO
411 return Z_STREAM_ERROR;
412#else
413 strm->zfree = zcfree;
414#endif
415
416#ifdef FASTEST
417 if (level != 0) level = 1;
418#else
419 if (level == Z_DEFAULT_COMPRESSION) level = 6;
420#endif
421
422 if (windowBits < 0) { /* suppress zlib wrapper */
423 wrap = 0;
424 if (windowBits < -15)
425 return Z_STREAM_ERROR;
426 windowBits = -windowBits;
427 }
428#ifdef GZIP
429 else if (windowBits > 15) {
430 wrap = 2; /* write gzip wrapper instead */
431 windowBits -= 16;
432 }
433#endif
434 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
435 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
436 strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
437 return Z_STREAM_ERROR;
438 }
439 if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
440 s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
441 if (s == Z_NULL) return Z_MEM_ERROR;
442 zmemzero(s, sizeof(deflate_state));
443 strm->state = (struct internal_state FAR *)s;
444 s->strm = strm;

Callers 1

deflateInit_Function · 0.85

Calls 3

zmemzeroFunction · 0.85
deflateEndFunction · 0.85
deflateResetFunction · 0.85

Tested by

no test coverage detected