MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / updatewindow

Function updatewindow

extlibs/minizip/src/inflate.c:410–465  ·  view source on GitHub ↗

Update the window with the last wsize (normally 32K) bytes written before returning. If window does not exist yet, create it. This is only called when a window is already in use, or when output has been written during this inflate call, but the end of the deflate stream has not been reached yet. It is also called to create a window for dictionary data when a dictionary is loaded.

(strm, end, copy)

Source from the content-addressed store, hash-verified

408 The advantage may be dependent on the size of the processor's data caches.
409 */
410local int updatewindow(strm, end, copy)
411z_streamp strm;
412const Bytef* end;
413
414unsigned copy;
415{
416 struct inflate_state FAR * state;
417 unsigned dist;
418
419 state = (struct inflate_state FAR *)strm->state;
420
421 /* if it hasn't been done already, allocate space for the window */
422 if (state->window == Z_NULL)
423 {
424 state->window = (unsigned char FAR *)
425 ZALLOC(strm, 1U << state->wbits,
426 sizeof(unsigned char));
427 if (state->window == Z_NULL) return 1;
428 }
429
430 /* if window not in use yet, initialize */
431 if (state->wsize == 0)
432 {
433 state->wsize = 1U << state->wbits;
434 state->wnext = 0;
435 state->whave = 0;
436 }
437
438 /* copy state->wsize or less output bytes into the circular window */
439 if (copy >= state->wsize)
440 {
441 zmemcpy(state->window, end - state->wsize, state->wsize);
442 state->wnext = 0;
443 state->whave = state->wsize;
444 }
445 else
446 {
447 dist = state->wsize - state->wnext;
448 if (dist > copy) dist = copy;
449 zmemcpy(state->window + state->wnext, end - copy, dist);
450 copy -= dist;
451 if (copy)
452 {
453 zmemcpy(state->window, end - copy, copy);
454 state->wnext = copy;
455 state->whave = state->wsize;
456 }
457 else
458 {
459 state->wnext += dist;
460 if (state->wnext == state->wsize) state->wnext = 0;
461 if (state->whave < state->wsize) state->whave += dist;
462 }
463 }
464 return 0;
465}
466
467/* Macros for inflate(): */

Callers 1

inflate.cFile · 0.85

Calls 1

zmemcpyFunction · 0.85

Tested by

no test coverage detected