MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / deflateInit2_

Function deflateInit2_

zlib/deflate.c:216–312  ·  view source on GitHub ↗

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

(strm, level, method, windowBits, memLevel, strategy,
                  version, stream_size)

Source from the content-addressed store, hash-verified

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

Callers 1

deflateInit_Function · 0.85

Calls 2

deflateEndFunction · 0.85
deflateResetFunction · 0.85

Tested by

no test coverage detected