MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / deflateInit2_

Function deflateInit2_

extern/zlib/src/deflate.c:379–524  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

deflateInit_Function · 0.85

Calls 2

deflateEndFunction · 0.85
deflateResetFunction · 0.85

Tested by

no test coverage detected