Lines Matching refs:strm

81 local void flush_pending  OF((z_streamp strm));
82 local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
189 int ZEXPORT deflateInit_(strm, level, version, stream_size)
190 z_streamp strm;
195 return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
197 /* To do: ignore strm->next_in if we use it as window */
201 int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
203 z_streamp strm;
225 if (strm == Z_NULL) return Z_STREAM_ERROR;
227 strm->msg = Z_NULL;
228 if (strm->zalloc == Z_NULL) {
229 strm->zalloc = zcalloc;
230 strm->opaque = (voidpf)0;
232 if (strm->zfree == Z_NULL) strm->zfree = zcfree;
248 s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
250 strm->state = (struct internal_state FAR *)s;
251 s->strm = strm;
263 s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
264 s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
265 s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
269 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
275 strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
276 deflateEnd (strm);
286 return deflateReset(strm);
290 int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
291 z_streamp strm;
300 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
301 strm->state->status != INIT_STATE) return Z_STREAM_ERROR;
303 s = strm->state;
304 strm->adler = adler32(strm->adler, dictionary, dictLength);
331 int ZEXPORT deflateReset (strm)
332 z_streamp strm;
336 if (strm == Z_NULL || strm->state == Z_NULL ||
337 strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR;
339 strm->total_in = strm->total_out = 0;
340 strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
341 strm->data_type = Z_UNKNOWN;
343 s = (deflate_state *)strm->state;
351 strm->adler = 1;
361 int ZEXPORT deflateParams(strm, level, strategy)
362 z_streamp strm;
370 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
371 s = strm->state;
381 if (func != configuration_table[level].func && strm->total_in != 0) {
383 err = deflate(strm, Z_PARTIAL_FLUSH);
412 * to avoid allocating a large strm->next_out buffer and copying into it.
415 local void flush_pending(strm)
416 z_streamp strm;
418 unsigned len = strm->state->pending;
420 if (len > strm->avail_out) len = strm->avail_out;
423 zmemcpy(strm->next_out, strm->state->pending_out, len);
424 strm->next_out += len;
425 strm->state->pending_out += len;
426 strm->total_out += len;
427 strm->avail_out -= len;
428 strm->state->pending -= len;
429 if (strm->state->pending == 0) {
430 strm->state->pending_out = strm->state->pending_buf;
435 int ZEXPORT deflate (strm, flush)
436 z_streamp strm;
442 if (strm == Z_NULL || strm->state == Z_NULL ||
446 s = strm->state;
448 if (strm->next_out == Z_NULL ||
449 (strm->next_in == Z_NULL && strm->avail_in != 0) ||
451 ERR_RETURN(strm, Z_STREAM_ERROR);
453 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
455 s->strm = strm; /* just in case */
475 putShortMSB(s, (uInt)(strm->adler >> 16));
476 putShortMSB(s, (uInt)(strm->adler & 0xffff));
478 strm->adler = 1L;
483 flush_pending(strm);
484 if (strm->avail_out == 0) {
499 } else if (strm->avail_in == 0 && flush <= old_flush &&
501 ERR_RETURN(strm, Z_BUF_ERROR);
505 if (s->status == FINISH_STATE && strm->avail_in != 0) {
506 ERR_RETURN(strm, Z_BUF_ERROR);
511 if (strm->avail_in != 0 || s->lookahead != 0 ||
521 if (strm->avail_out == 0) {
545 flush_pending(strm);
546 if (strm->avail_out == 0) {
552 Assert(strm->avail_out > 0, "bug2");
558 putShortMSB(s, (uInt)(strm->adler >> 16));
559 putShortMSB(s, (uInt)(strm->adler & 0xffff));
560 flush_pending(strm);
569 int ZEXPORT deflateEnd (strm)
570 z_streamp strm;
574 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
576 status = strm->state->status;
583 TRY_FREE(strm, strm->state->pending_buf);
584 TRY_FREE(strm, strm->state->head);
585 TRY_FREE(strm, strm->state->prev);
586 TRY_FREE(strm, strm->state->window);
588 ZFREE(strm, strm->state);
589 strm->state = Z_NULL;
623 ds->strm = dest;
658 * allocating a large strm->next_in buffer and copying from it.
661 local int read_buf(strm, buf, size)
662 z_streamp strm;
666 unsigned len = strm->avail_in;
671 strm->avail_in -= len;
673 if (!strm->state->noheader) {
674 strm->adler = adler32(strm->adler, strm->next_in, len);
676 zmemcpy(buf, strm->next_in, len);
677 strm->next_in += len;
678 strm->total_in += len;
1017 if (s->strm->avail_in == 0) return;
1032 n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
1047 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1061 flush_pending(s->strm); \
1068 if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
1331 if (s->strm->avail_out == 0) return need_more;