Lines Matching refs:strm
32 z_stream strm;
33 mem_setup(&strm) initializes the memory tracking and sets the
34 zalloc, zfree, and opaque members of strm to use
35 memory tracking for all zlib operations on strm
36 mem_limit(&strm, limit) sets a limit on the total bytes requested -- a
41 mem_used(&strm, "msg") prints to stderr "msg" and the total bytes used
42 mem_high(&strm, "msg") prints to stderr "msg" and the high water mark
43 mem_done(&strm, "msg") ends memory tracking, releases all allocations
50 strm members to Z_NULL to use the default memory
52 using strm.
158 local void mem_setup(z_stream *strm)
170 strm->opaque = zone;
171 strm->zalloc = mem_alloc;
172 strm->zfree = mem_free;
176 local void mem_limit(z_stream *strm, size_t limit)
178 struct mem_zone *zone = strm->opaque;
184 local void mem_used(z_stream *strm, char *prefix)
186 struct mem_zone *zone = strm->opaque;
192 local void mem_high(z_stream *strm, char *prefix)
194 struct mem_zone *zone = strm->opaque;
200 local void mem_done(z_stream *strm, char *prefix)
204 struct mem_zone *zone = strm->opaque;
207 mem_high(strm, prefix);
231 strm->opaque = Z_NULL;
232 strm->zalloc = Z_NULL;
233 strm->zfree = Z_NULL;
290 z_stream strm, copy;
293 mem_setup(&strm);
294 strm.avail_in = 0;
295 strm.next_in = Z_NULL;
296 ret = inflateInit2(&strm, win);
298 mem_done(&strm, what);
309 ret = inflateGetHeader(&strm, &head); assert(ret == Z_OK);
314 strm.avail_in = step;
316 strm.next_in = in;
318 strm.avail_out = len;
319 strm.next_out = out;
320 ret = inflate(&strm, Z_NO_FLUSH); assert(err == 9 || ret == err);
324 ret = inflateSetDictionary(&strm, in, 1);
326 mem_limit(&strm, 1);
327 ret = inflateSetDictionary(&strm, out, 0);
329 mem_limit(&strm, 0);
330 ((struct inflate_state *)strm.state)->mode = DICT;
331 ret = inflateSetDictionary(&strm, out, 0);
333 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR);
335 ret = inflateCopy(©, &strm); assert(ret == Z_OK);
338 have += strm.avail_in;
339 strm.avail_in = step > have ? have : step;
340 have -= strm.avail_in;
341 } while (strm.avail_in);
344 ret = inflateReset2(&strm, -8); assert(ret == Z_OK);
345 ret = inflateEnd(&strm); assert(ret == Z_OK);
346 mem_done(&strm, what);
353 z_stream strm;
355 mem_setup(&strm);
356 strm.avail_in = 0;
357 strm.next_in = Z_NULL;
358 ret = inflateInit(&strm); assert(ret == Z_OK);
359 mem_used(&strm, "inflate init");
360 ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK);
361 ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK);
362 ret = inflateSetDictionary(&strm, Z_NULL, 0);
364 ret = inflateEnd(&strm); assert(ret == Z_OK);
365 mem_done(&strm, "prime");
373 mem_setup(&strm);
374 strm.avail_in = 0;
375 strm.next_in = Z_NULL;
376 ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream));
378 mem_done(&strm, "wrong version");
380 strm.avail_in = 0;
381 strm.next_in = Z_NULL;
382 ret = inflateInit(&strm); assert(ret == Z_OK);
383 ret = inflateEnd(&strm); assert(ret == Z_OK);
391 z_stream strm, copy;
413 mem_setup(&strm);
414 strm.avail_in = 0;
415 strm.next_in = Z_NULL;
416 ret = inflateInit2(&strm, -8);
417 strm.avail_in = 2;
418 strm.next_in = (void *)"\x63";
419 strm.avail_out = 1;
420 strm.next_out = (void *)&ret;
421 mem_limit(&strm, 1);
422 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR);
423 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR);
424 mem_limit(&strm, 0);
426 ret = inflateSetDictionary(&strm, dict, 257);
428 mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256);
429 ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK);
430 strm.avail_in = 2;
431 strm.next_in = (void *)"\x80";
432 ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR);
433 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR);
434 strm.avail_in = 4;
435 strm.next_in = (void *)"\0\0\xff\xff";
436 ret = inflateSync(&strm); assert(ret == Z_OK);
437 (void)inflateSyncPoint(&strm);
438 ret = inflateCopy(©, &strm); assert(ret == Z_MEM_ERROR);
439 mem_limit(&strm, 0);
440 ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR);
441 strm);
442 ret = inflateEnd(&strm); assert(ret == Z_OK);
443 mem_done(&strm, "miscellaneous, force memory errors");
473 z_stream strm;
484 mem_setup(&strm);
485 ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK);
486 strm.avail_in = 2;
487 strm.next_in = (void *)"\x03";
488 ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
491 strm.avail_in = 3;
492 strm.next_in = (void *)"\x63\x00";
493 ret = inflateBack(&strm, pull, Z_NULL, push, &strm);
496 ret = inflateBack(&strm, pull, &strm, push, Z_NULL);
498 ret = inflateBackEnd(&strm); assert(ret == Z_OK);
499 mem_done(&strm, "inflateBack bad state");
501 ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK);
502 ret = inflateBackEnd(&strm); assert(ret == Z_OK);
513 z_stream strm;
531 mem_setup(&strm);
532 strm.avail_in = 0;
533 strm.next_in = Z_NULL;
534 ret = inflateInit2(&strm, err < 0 ? 47 : -15);
536 strm.avail_in = len;
537 strm.next_in = in;
539 strm.avail_out = size;
540 strm.next_out = out;
541 ret = inflate(&strm, Z_TREES);
545 } while (strm.avail_in || strm.avail_out == 0);
548 assert(strcmp(id, strm.msg) == 0);
550 inflateEnd(&strm);
551 mem_done(&strm, prefix);
557 mem_setup(&strm);
558 ret = inflateBackInit(&strm, 15, win);
560 strm.avail_in = len;
561 strm.next_in = in;
562 ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
566 assert(strcmp(id, strm.msg) == 0);
568 inflateBackEnd(&strm);
569 mem_done(&strm, prefix);