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

Function deflateSetDictionary

zlib/deflate.c:315–354  ·  view source on GitHub ↗

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

(strm, dictionary, dictLength)

Source from the content-addressed store, hash-verified

313
314/* ========================================================================= */
315int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
316 z_streamp strm;
317 const Bytef *dictionary;
318 uInt dictLength;
319{
320 deflate_state *s;
321 uInt length = dictLength;
322 uInt n;
323 IPos hash_head = 0;
324
325 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
326 strm->state->wrap == 2 ||
327 (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
328 return Z_STREAM_ERROR;
329
330 s = strm->state;
331 if (s->wrap)
332 strm->adler = adler32(strm->adler, dictionary, dictLength);
333
334 if (length < MIN_MATCH) return Z_OK;
335 if (length > MAX_DIST(s)) {
336 length = MAX_DIST(s);
337 dictionary += dictLength - length; /* use the tail of the dictionary */
338 }
339 zmemcpy(s->window, dictionary, length);
340 s->strstart = length;
341 s->block_start = (long)length;
342
343 /* Insert all strings in the hash table (except for the last two bytes).
344 * s->lookahead stays null, so s->ins_h will be recomputed at the next
345 * call of fill_window.
346 */
347 s->ins_h = s->window[0];
348 UPDATE_HASH(s, s->ins_h, s->window[1]);
349 for (n = 0; n <= length - MIN_MATCH; n++) {
350 INSERT_STRING(s, n, hash_head);
351 }
352 if (hash_head) hash_head = 0; /* to make compiler happy */
353 return Z_OK;
354}
355
356/* ========================================================================= */
357int ZEXPORT deflateReset (strm)

Callers

nothing calls this directly

Calls 2

adler32Function · 0.85
zmemcpyFunction · 0.85

Tested by

no test coverage detected