========================================================================= */
(strm, dictionary, dictLength)
| 321 | |
| 322 | /* ========================================================================= */ |
| 323 | int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) |
| 324 | z_streamp strm; |
| 325 | const Bytef *dictionary; |
| 326 | uInt dictLength; |
| 327 | { |
| 328 | deflate_state *s; |
| 329 | uInt str, n; |
| 330 | int wrap; |
| 331 | unsigned avail; |
| 332 | z_const unsigned char *next; |
| 333 | |
| 334 | if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) |
| 335 | return Z_STREAM_ERROR; |
| 336 | s = strm->state; |
| 337 | wrap = s->wrap; |
| 338 | if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) |
| 339 | return Z_STREAM_ERROR; |
| 340 | |
| 341 | /* when using zlib wrappers, compute Adler-32 for provided dictionary */ |
| 342 | if (wrap == 1) |
| 343 | strm->adler = adler32(strm->adler, dictionary, dictLength); |
| 344 | s->wrap = 0; /* avoid computing Adler-32 in read_buf */ |
| 345 | |
| 346 | /* if dictionary would fill window, just replace the history */ |
| 347 | if (dictLength >= s->w_size) { |
| 348 | if (wrap == 0) { /* already empty otherwise */ |
| 349 | CLEAR_HASH(s); |
| 350 | s->strstart = 0; |
| 351 | s->block_start = 0L; |
| 352 | s->insert = 0; |
| 353 | } |
| 354 | dictionary += dictLength - s->w_size; /* use the tail */ |
| 355 | dictLength = s->w_size; |
| 356 | } |
| 357 | |
| 358 | /* insert dictionary into window and hash */ |
| 359 | avail = strm->avail_in; |
| 360 | next = strm->next_in; |
| 361 | strm->avail_in = dictLength; |
| 362 | strm->next_in = (z_const Bytef *)dictionary; |
| 363 | fill_window(s); |
| 364 | while (s->lookahead >= MIN_MATCH) { |
| 365 | str = s->strstart; |
| 366 | n = s->lookahead - (MIN_MATCH-1); |
| 367 | do { |
| 368 | UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); |
| 369 | #ifndef FASTEST |
| 370 | s->prev[str & s->w_mask] = s->head[s->ins_h]; |
| 371 | #endif |
| 372 | s->head[s->ins_h] = (Pos)str; |
| 373 | str++; |
| 374 | } while (--n); |
| 375 | s->strstart = str; |
| 376 | s->lookahead = MIN_MATCH-1; |
| 377 | fill_window(s); |
| 378 | } |
| 379 | s->strstart += s->lookahead; |
| 380 | s->block_start = (long)s->strstart; |
nothing calls this directly
no test coverage detected