author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 29 Sep 2004 06:03:44 +0000 | |
changeset 656 | d2c34dbf2c83 |
parent 602 | 691c1eadb8b7 |
permissions | -rw-r--r-- |
602
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* zutil.c -- target dependent utility functions for the compression library |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
* Copyright (C) 1995-2003 Jean-loup Gailly. |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
* For conditions of distribution and use, see copyright notice in zlib.h |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
*/ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
/* @(#) $Id: zutil.c,v 1.1 2003/12/07 05:29:20 icculus Exp $ */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
#include "zutil.h" |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
#ifndef NO_DUMMY_DECL |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
struct internal_state {int dummy;}; /* for buggy compilers */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
#ifndef STDC |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
extern void exit OF((int)); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
const char * const z_errmsg[10] = { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
"need dictionary", /* Z_NEED_DICT 2 */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
"stream end", /* Z_STREAM_END 1 */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
"", /* Z_OK 0 */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
"file error", /* Z_ERRNO (-1) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
"stream error", /* Z_STREAM_ERROR (-2) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
"data error", /* Z_DATA_ERROR (-3) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
"insufficient memory", /* Z_MEM_ERROR (-4) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
"buffer error", /* Z_BUF_ERROR (-5) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 |
"incompatible version",/* Z_VERSION_ERROR (-6) */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
""}; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 |
const char * ZEXPORT zlibVersion() |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
return ZLIB_VERSION; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 |
uLong ZEXPORT zlibCompileFlags() |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
uLong flags; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
flags = 0; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 |
switch (sizeof(uInt)) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
case 2: break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 |
case 4: flags += 1; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 |
case 8: flags += 2; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 |
default: flags += 3; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
switch (sizeof(uLong)) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 |
case 2: break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
case 4: flags += 1 << 2; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 |
case 8: flags += 2 << 2; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 |
default: flags += 3 << 2; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
switch (sizeof(voidpf)) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
case 2: break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 |
case 4: flags += 1 << 4; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
case 8: flags += 2 << 4; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
default: flags += 3 << 4; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
switch (sizeof(z_off_t)) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
case 2: break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
case 4: flags += 1 << 6; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
case 8: flags += 2 << 6; break; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
default: flags += 3 << 6; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
#ifdef DEBUG |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 |
flags += 1 << 8; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
#if defined(ASMV) || defined(ASMINF) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 |
flags += 1 << 9; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 |
#ifdef ZLIB_WINAPI |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 |
flags += 1 << 10; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 |
#ifdef BUILDFIXED |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 |
flags += 1 << 12; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 |
#ifdef DYNAMIC_CRC_TABLE |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 |
flags += 1 << 13; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 |
#ifdef NO_GZCOMPRESS |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 |
flags += 1 << 16; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 |
#ifdef NO_GZIP |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 |
flags += 1 << 17; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 |
#ifdef PKZIP_BUG_WORKAROUND |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 |
flags += 1 << 20; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 |
#ifdef FASTEST |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 |
flags += 1 << 21; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 |
#ifdef STDC |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 |
# ifdef NO_vsnprintf |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 |
flags += 1 << 25; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 |
# ifdef HAS_vsprintf_void |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 |
flags += 1 << 26; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 |
# else |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 |
# ifdef HAS_vsnprintf_void |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 |
flags += 1 << 26; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 |
#else |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 |
flags += 1 << 24; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 |
# ifdef NO_snprintf |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 |
flags += 1 << 25; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 |
# ifdef HAS_sprintf_void |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 |
flags += 1 << 26; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 |
# else |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 |
# ifdef HAS_snprintf_void |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 |
flags += 1 << 26; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 |
return flags; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 |
#ifdef DEBUG |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 |
# ifndef verbose |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 |
# define verbose 0 |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 |
# endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 |
int z_verbose = verbose; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 |
void z_error (m) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 |
char *m; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 |
fprintf(stderr, "%s\n", m); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 |
exit(1); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 |
/* exported to allow conversion of error code to string for compress() and |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
* uncompress() |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 |
*/ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
const char * ZEXPORT zError(err) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
int err; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 |
return ERR_MSG(err); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 |
#if defined(_WIN32_WCE) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 |
/* does not exist on WCE */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 |
int errno = 0; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
#ifndef HAVE_MEMCPY |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
void zmemcpy(dest, source, len) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 |
Bytef* dest; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 |
const Bytef* source; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 |
uInt len; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 |
if (len == 0) return; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 |
do { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
*dest++ = *source++; /* ??? to be unrolled */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 |
} while (--len != 0); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 |
int zmemcmp(s1, s2, len) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 |
const Bytef* s1; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 |
const Bytef* s2; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
uInt len; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
uInt j; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
for (j = 0; j < len; j++) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
return 0; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 |
void zmemzero(dest, len) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 |
Bytef* dest; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
uInt len; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
if (len == 0) return; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
do { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 |
*dest++ = 0; /* ??? to be unrolled */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 |
} while (--len != 0); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
#ifdef SYS16BIT |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 |
#ifdef __TURBOC__ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 |
/* Turbo C in 16-bit mode */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 |
# define MY_ZCALLOC |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 |
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
* and farmalloc(64K) returns a pointer with an offset of 8, so we |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 |
* must fix the pointer. Warning: the pointer must be put back to its |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 |
* original form in order to free it, use zcfree(). |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 |
*/ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 |
#define MAX_PTR 10 |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 |
/* 10*64K = 640K */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 |
local int next_ptr = 0; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
typedef struct ptr_table_s { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 |
voidpf org_ptr; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 |
voidpf new_ptr; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 |
} ptr_table; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 |
local ptr_table table[MAX_PTR]; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 |
/* This table is used to remember the original form of pointers |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
* to large buffers (64K). Such pointers are normalized with a zero offset. |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 |
* Since MSDOS is not a preemptive multitasking OS, this table is not |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 |
* protected from concurrent access. This hack doesn't work anyway on |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 |
* a protected system like OS/2. Use Microsoft C instead. |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 |
*/ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 |
voidpf buf = opaque; /* just to make some compilers happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 |
ulg bsize = (ulg)items*size; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
222 |
/* If we allocate less than 65520 bytes, we assume that farmalloc |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 |
* will return a usable pointer which doesn't have to be normalized. |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
224 |
*/ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 |
if (bsize < 65520L) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 |
buf = farmalloc(bsize); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 |
if (*(ush*)&buf != 0) return buf; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 |
} else { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 |
buf = farmalloc(bsize + 16L); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
if (buf == NULL || next_ptr >= MAX_PTR) return NULL; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 |
table[next_ptr].org_ptr = buf; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 |
/* Normalize the pointer to seg:0 */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 |
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
236 |
*(ush*)&buf = 0; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 |
table[next_ptr++].new_ptr = buf; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 |
return buf; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 |
void zcfree (voidpf opaque, voidpf ptr) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
242 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
int n; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
if (*(ush*)&ptr != 0) { /* object < 64K */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
farfree(ptr); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 |
return; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
/* Find the original pointer */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
for (n = 0; n < next_ptr; n++) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
if (ptr != table[n].new_ptr) continue; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
farfree(table[n].org_ptr); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
while (++n < next_ptr) { |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 |
table[n-1] = table[n]; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
next_ptr--; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 |
return; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 |
ptr = opaque; /* just to make some compilers happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
Assert(0, "zcfree: ptr not found"); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 |
#endif /* __TURBOC__ */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
#ifdef M_I86 |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
/* Microsoft C in 16-bit mode */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
# define MY_ZCALLOC |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 |
# define _halloc halloc |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 |
# define _hfree hfree |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
if (opaque) opaque = 0; /* to make compiler happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 |
return _halloc((long)items, size); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 |
void zcfree (voidpf opaque, voidpf ptr) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
283 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 |
if (opaque) opaque = 0; /* to make compiler happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
285 |
_hfree(ptr); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
287 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
288 |
#endif /* M_I86 */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
289 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
290 |
#endif /* SYS16BIT */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
291 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
292 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
293 |
#ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
294 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
295 |
#ifndef STDC |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 |
extern voidp malloc OF((uInt size)); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 |
extern voidp calloc OF((uInt items, uInt size)); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
298 |
extern void free OF((voidpf ptr)); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
299 |
#endif |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 |
voidpf zcalloc (opaque, items, size) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 |
voidpf opaque; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
303 |
unsigned items; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 |
unsigned size; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
306 |
if (opaque) items += size - size; /* make compiler happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 |
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
308 |
(voidpf)calloc(items, size); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
309 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
310 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
311 |
void zcfree (opaque, ptr) |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
312 |
voidpf opaque; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
313 |
voidpf ptr; |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
314 |
{ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
315 |
free(ptr); |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
316 |
if (opaque) return; /* make compiler happy */ |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 |
} |
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
318 |
|
691c1eadb8b7
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
319 |
#endif /* MY_ZCALLOC */ |