59 struct mem_item *next;
64 struct mem_item *
first;
65 size_t total, highwater;
74 struct mem_item *item;
75 struct mem_zone *zone = mem;
76 size_t len = count * (size_t)size;
79 if (zone ==
NULL || (zone->limit && zone->total + len > zone->limit))
87 memset(ptr, 0xa5, len);
90 item =
malloc(
sizeof(
struct mem_item));
99 item->next = zone->first;
103 zone->total += item->size;
104 if (zone->total > zone->highwater)
105 zone->highwater = zone->total;
114 struct mem_item *item, *next;
115 struct mem_zone *zone = mem;
127 if (next->ptr == ptr)
128 zone->first = next->next;
133 }
while (next !=
NULL && next->ptr != ptr);
135 item->next = next->next;
144 zone->total -= next->size;
160 struct mem_zone *zone;
162 zone =
malloc(
sizeof(
struct mem_zone));
163 assert(zone !=
NULL);
178 struct mem_zone *zone = strm->
opaque;
186 struct mem_zone *zone = strm->
opaque;
188 fprintf(stderr,
"%s: %lu allocated\n", prefix, zone->total);
194 struct mem_zone *zone = strm->
opaque;
196 fprintf(stderr,
"%s: %lu high water mark\n", prefix, zone->highwater);
203 struct mem_item *item, *next;
204 struct mem_zone *zone = strm->
opaque;
211 while (item !=
NULL) {
220 if (count || zone->total)
221 fprintf(stderr,
"** %s: %lu bytes in %d blocks not freed\n",
222 prefix, zone->total, count);
224 fprintf(stderr,
"** %s: %d frees not LIFO\n", prefix, zone->notlifo);
226 fprintf(stderr,
"** %s: %d frees not recognized\n",
227 prefix, zone->rogue);
250 in =
malloc((strlen(hex) + 1) >> 1);
256 if (*hex >=
'0' && *hex <=
'9')
257 val = (val << 4) + *hex -
'0';
258 else if (*hex >=
'A' && *hex <=
'F')
259 val = (val << 4) + *hex -
'A' + 10;
260 else if (*hex >=
'a' && *hex <=
'f')
261 val = (val << 4) + *hex -
'a' + 10;
262 else if (val != 1 && val < 32)
265 in[next++] = val & 0xff;
271 in = reallocf(in, next);
289 unsigned char *
in, *
out;
311 in =
h2b(hex, &have); assert(in !=
NULL);
312 if (step == 0 || step > have)
367 inf(
"63 0",
"force window allocation", 0, -15, 1,
Z_OK);
368 inf(
"63 18 5",
"force window replacement", 0, -8, 259,
Z_OK);
369 inf(
"63 18 68 30 d0 0 0",
"force split window update", 4, -8, 259,
Z_OK);
384 fputs(
"inflate built-in memory routines\n", stderr);
392 unsigned char dict[257];
397 fputs(
"inflate bad parameters\n", stderr);
402 inf(
"8 99",
"set window size from header", 0, 0, 0,
Z_OK);
405 inf(
"1f 8b 8 1e 0 0 0 0 0 0 1 0 0 0 0 0 0",
"bad header crc", 0, 47, 1,
407 inf(
"1f 8b 8 2 0 0 0 0 0 0 1d 26 3 0 0 0 0 0 0 0 0 0",
"check gzip length",
411 inf(
"78 9c 63 0",
"compute adler32", 0, 15, 1,
Z_OK);
425 memset(dict, 0, 257);
435 strm.
next_in = (
void *)
"\0\0\xff\xff";
443 mem_done(&strm,
"miscellaneous, force memory errors");
449 static unsigned int next = 0;
450 static unsigned char dat[] = {0x63, 0, 2, 0};
457 state = (
void *)((
z_stream *)desc)->state;
460 return next <
sizeof(dat) ? (*buf = dat + next++, 1) : 0;
474 unsigned char win[32768];
482 fputs(
"inflateBack bad parameters\n", stderr);
492 strm.
next_in = (
void *)
"\x63\x00";
499 mem_done(&strm,
"inflateBack bad state");
503 fputs(
"inflateBack built-in memory routines\n", stderr);
507 local int try(
char *hex,
char *
id,
int err)
511 unsigned char *
in, *
out, *win;
525 prefix =
malloc(strlen(
id) + 6);
526 assert(prefix !=
NULL);
530 strcat(prefix,
"-late");
548 assert(strcmp(
id, strm.
msg) == 0);
556 strcat(prefix,
"-back");
566 assert(strcmp(
id, strm.
msg) == 0);
583 try(
"0 0 0 0 0",
"invalid stored block lengths", 1);
584 try(
"3 0",
"fixed", 0);
585 try(
"6",
"invalid block type", 1);
586 try(
"1 1 0 fe ff 0",
"stored", 0);
587 try(
"fc 0 0",
"too many length or distance symbols", 1);
588 try(
"4 0 fe ff",
"invalid code lengths set", 1);
589 try(
"4 0 24 49 0",
"invalid bit length repeat", 1);
590 try(
"4 0 24 e9 ff ff",
"invalid bit length repeat", 1);
591 try(
"4 0 24 e9 ff 6d",
"invalid code -- missing end-of-block", 1);
592 try(
"4 80 49 92 24 49 92 24 71 ff ff 93 11 0",
593 "invalid literal/lengths set", 1);
594 try(
"4 80 49 92 24 49 92 24 f b4 ff ff c3 84",
"invalid distances set", 1);
595 try(
"4 c0 81 8 0 0 0 0 20 7f eb b 0 0",
"invalid literal/length code", 1);
596 try(
"2 7e ff ff",
"invalid distance code", 1);
597 try(
"c c0 81 0 0 0 0 0 90 ff 6b 4 0",
"invalid distance too far back", 1);
600 try(
"1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1",
"incorrect data check", -1);
601 try(
"1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1",
602 "incorrect length check", -1);
603 try(
"5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c",
"pull 17", 0);
604 try(
"5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f",
606 try(
"ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f",
"length extra", 0);
607 try(
"ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c",
608 "long distance and extra", 0);
609 try(
"ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " 610 "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6",
"window end", 0);
611 inf(
"2 8 20 80 0 3 0",
"inflate_fast TYPE return", 0, -15, 258,
613 inf(
"63 18 5 40 c 0",
"window wrap", 3, -8, 300,
Z_OK);
626 for (bits = 0; bits < 15; bits++)
627 lens[bits] = (
unsigned short)(bits + 1);
637 fputs(
"inflate_table not enough errors\n", stderr);
643 inf(
"e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68" 644 " ff 7f 0f 0 0 0",
"fast length extra bits", 0, -8, 258,
Z_DATA_ERROR);
645 inf(
"25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49" 646 " 50 fe ff ff 3f 0 0",
"fast distance extra bits", 0, -8, 258,
648 inf(
"3 7e 0 0 0 0 0",
"fast invalid distance code", 0, -8, 258,
650 inf(
"1b 7 0 0 0 0 0",
"fast invalid literal/length code", 0, -8, 258,
652 inf(
"d c7 1 ae eb 38 c 4 41 a0 87 72 de df fb 1f b8 36 b1 38 5d ff ff 0",
653 "fast 2nd level codes and too far back", 0, -8, 258,
Z_DATA_ERROR);
654 inf(
"63 18 5 8c 10 8 0 0 0 0",
"very common case", 0, -8, 259,
Z_OK);
655 inf(
"63 60 60 18 c9 0 8 18 18 18 26 c0 28 0 29 0 0 0",
656 "contiguous and wrap around window", 6, -8, 259,
Z_OK);
657 inf(
"63 0 3 0 0 0 0 0",
"copy direct from output", 0, -8, 259,
local int push(void *desc, unsigned char *buf, unsigned len)
local void mem_limit(z_stream *strm, size_t limit)
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
local void mem_used(z_stream *strm, char *prefix)
local void cover_trees(void)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
unsigned short prefix[65536]
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
local void * mem_alloc(void *mem, unsigned count, unsigned size)
#define inflateInit2(strm, windowBits)
#define inflateBackInit(strm, windowBits, window)
GLenum GLuint GLenum GLsizei const GLchar * buf
local void cover_support(void)
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
local void cover_wrap(void)
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
#define inflateInit(strm)
local void mem_done(z_stream *strm, char *prefix)
local void cover_back(void)
int ZEXPORT inflateSyncPoint(z_streamp strm)
local int out(void *out_desc, unsigned char *buf, unsigned len)
local unsigned char * h2b(const char *hex, unsigned *len)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
int ZEXPORT inflateSync(z_streamp strm)
int ZEXPORT inflate(z_streamp strm, int flush)
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
local void cover_inflate(void)
int ZEXPORT inflateBackEnd(z_streamp strm)
local void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err)
const char *ZEXPORT zlibVersion()
local unsigned pull(void *desc, unsigned char **buf)
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
local void cover_fast(void)
local void mem_high(z_stream *strm, char *prefix)
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
GLuint GLuint GLsizei count
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
local void mem_free(void *mem, void *ptr)
struct internal_state FAR * state
GLenum GLsizei GLenum GLenum const GLvoid * table
long ZEXPORT inflateMark(z_streamp strm)
int ZEXPORT inflateEnd(z_streamp strm)
local void mem_setup(z_stream *strm)