MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / inflateInit2

Function inflateInit2

src/Setup/unzip.cpp:2381–2442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2379
2380
2381int inflateInit2(z_streamp z)
2382{ const char *version = ZLIB_VERSION; int stream_size = sizeof(z_stream);
2383 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) return Z_VERSION_ERROR;
2384
2385 int w = -15; // MAX_WBITS: 32K LZ77 window.
2386 // Warning: reducing MAX_WBITS makes minigzip unable to extract .gz files created by gzip.
2387 // The memory requirements for deflate are (in bytes):
2388 // (1 << (windowBits+2)) + (1 << (memLevel+9))
2389 // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
2390 // plus a few kilobytes for small objects. For example, if you want to reduce
2391 // the default memory requirements from 256K to 128K, compile with
2392 // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
2393 // Of course this will generally degrade compression (there's no free lunch).
2394 //
2395 // The memory requirements for inflate are (in bytes) 1 << windowBits
2396 // that is, 32K for windowBits=15 (default value) plus a few kilobytes
2397 // for small objects.
2398
2399 // initialize state
2400 if (z == Z_NULL) return Z_STREAM_ERROR;
2401 z->msg = Z_NULL;
2402 if (z->zalloc == Z_NULL)
2403 {
2404 z->zalloc = zcalloc;
2405 z->opaque = (voidpf)0;
2406 }
2407 if (z->zfree == Z_NULL) z->zfree = zcfree;
2408 if ((z->state = (struct internal_state *)
2409 ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
2410 return Z_MEM_ERROR;
2411 z->state->blocks = Z_NULL;
2412
2413 // handle undocumented nowrap option (no zlib header or check)
2414 z->state->nowrap = 0;
2415 if (w < 0)
2416 {
2417 w = - w;
2418 z->state->nowrap = 1;
2419 }
2420
2421 // set window size
2422 if (w < 8 || w > 15)
2423 {
2424 inflateEnd(z);
2425 return Z_STREAM_ERROR;
2426 }
2427 z->state->wbits = (uInt)w;
2428
2429 // create inflate_blocks state
2430 if ((z->state->blocks =
2431 inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
2432 == Z_NULL)
2433 {
2434 inflateEnd(z);
2435 return Z_MEM_ERROR;
2436 }
2437 LuTracev((stderr, "inflate: allocated\n"));
2438

Callers 1

unzOpenCurrentFileFunction · 0.85

Calls 3

inflateEndFunction · 0.85
inflate_blocks_newFunction · 0.85
inflateResetFunction · 0.85

Tested by

no test coverage detected