13z_const
char *
const z_errmsg[10] = {
14 (z_const
char *)
"need dictionary",
15 (z_const
char *)
"stream end",
17 (z_const
char *)
"file error",
18 (z_const
char *)
"stream error",
19 (z_const
char *)
"data error",
20 (z_const
char *)
"insufficient memory",
21 (z_const
char *)
"buffer error",
22 (z_const
char *)
"incompatible version",
27const char * ZEXPORT zlibVersion(
void) {
31uLong ZEXPORT zlibCompileFlags(
void) {
35 switch ((
int)(
sizeof(uInt))) {
37 case 4: flags += 1;
break;
38 case 8: flags += 2;
break;
41 switch ((
int)(
sizeof(uLong))) {
43 case 4: flags += 1 << 2;
break;
44 case 8: flags += 2 << 2;
break;
45 default: flags += 3 << 2;
47 switch ((
int)(
sizeof(voidpf))) {
49 case 4: flags += 1 << 4;
break;
50 case 8: flags += 2 << 4;
break;
51 default: flags += 3 << 4;
53 switch ((
int)(
sizeof(z_off_t))) {
55 case 4: flags += 1 << 6;
break;
56 case 8: flags += 2 << 6;
break;
57 default: flags += 3 << 6;
73#ifdef DYNAMIC_CRC_TABLE
82#ifdef PKZIP_BUG_WORKAROUND
88#if defined(STDC) || defined(Z_HAVE_STDARG_H)
91# ifdef HAS_vsprintf_void
95# ifdef HAS_vsnprintf_void
103# ifdef HAS_sprintf_void
107# ifdef HAS_snprintf_void
120int ZLIB_INTERNAL z_verbose = verbose;
122void ZLIB_INTERNAL z_error(
char *m) {
123 fprintf(stderr,
"%s\n", m);
131const char * ZEXPORT zError(
int err) {
135#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
145void ZLIB_INTERNAL zmemcpy(Bytef* dest,
const Bytef* source, uInt len) {
146 if (len == 0)
return;
149 }
while (--len != 0);
152int ZLIB_INTERNAL zmemcmp(
const Bytef* s1,
const Bytef* s2, uInt len) {
155 for (j = 0; j < len; j++) {
156 if (s1[j] != s2[j])
return 2*(s1[j] > s2[j])-1;
161void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
162 if (len == 0)
return;
165 }
while (--len != 0);
187local
int next_ptr = 0;
189typedef struct ptr_table_s {
194local ptr_table table[MAX_PTR];
202voidpf ZLIB_INTERNAL zcalloc(voidpf opaque,
unsigned items,
unsigned size) {
204 ulg bsize = (ulg)items*size;
211 if (bsize < 65520L) {
212 buf = farmalloc(bsize);
213 if (*(ush*)&buf != 0)
return buf;
215 buf = farmalloc(bsize + 16L);
217 if (buf == NULL || next_ptr >= MAX_PTR)
return NULL;
218 table[next_ptr].org_ptr = buf;
221 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
223 table[next_ptr++].new_ptr = buf;
227void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
232 if (*(ush*)&ptr != 0) {
237 for (n = 0; n < next_ptr; n++) {
238 if (ptr != table[n].new_ptr)
continue;
240 farfree(table[n].org_ptr);
241 while (++n < next_ptr) {
242 table[n-1] = table[n];
247 Assert(0,
"zcfree: ptr not found");
258#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
259# define _halloc halloc
263voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
265 return _halloc((
long)items, size);
268void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
281extern voidp malloc(uInt size);
282extern voidp calloc(uInt items, uInt size);
283extern void free(voidpf ptr);
286voidpf ZLIB_INTERNAL zcalloc(voidpf opaque,
unsigned items,
unsigned size) {
288 return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
289 (voidpf)calloc(items, size);
292void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {