Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Zlib
提交
25e53255
T
Third Party Zlib
项目概览
OpenHarmony
/
Third Party Zlib
大约 1 年 前同步成功
通知
15
Star
112
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Zlib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
25e53255
编写于
9月 09, 2011
作者:
M
Mark Adler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
zlib 0.95
上级
23c69f10
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
225 addition
and
140 deletion
+225
-140
ChangeLog
ChangeLog
+11
-0
Makefile.bor
Makefile.bor
+1
-0
Makefile.msc
Makefile.msc
+1
-0
Makefile.tc
Makefile.tc
+3
-1
README
README
+19
-20
deflate.c
deflate.c
+9
-9
deflate.h
deflate.h
+1
-0
example.c
example.c
+1
-1
gzio.c
gzio.c
+2
-2
inftrees.c
inftrees.c
+9
-9
trees.c
trees.c
+98
-42
zconf.h
zconf.h
+24
-19
zlib.h
zlib.h
+7
-7
zutil.c
zutil.c
+23
-20
zutil.h
zutil.h
+16
-10
未找到文件。
ChangeLog
浏览文件 @
25e53255
ChangeLog file for zlib
Changes in 0.95 (16 Aug 95)
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).
- default window size is same for compression and decompression
(it's now sufficient to set MAX_WBITS in zconf.h).
- voidp -> voidpf and voidnp -> voidp (for consistency with other
typedefs and because voidnp was not near in large model).
Changes in 0.94 (13 Aug 95)
- support MSDOS medium model
- fix deflate with flush (could sometimes generate bad output)
...
...
@@ -10,6 +20,7 @@ Changes in 0.94 (13 Aug 95)
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
- avoid complex expression in infcodes.c triggering Turbo C bug
- work around a problem with gcc on Alpha (in INSERT_STRING)
- don't use inline functions (problem with some gcc versions)
- allow renaming of Byte, uInt, etc... with #define.
...
...
Makefile.bor
浏览文件 @
25e53255
...
...
@@ -2,6 +2,7 @@
# Borland C++ ************ UNTESTED ***********
# To use, do "make -fmakefile.bor"
# To compile in small model, set below: MODEL=-ms
# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
...
...
Makefile.msc
浏览文件 @
25e53255
...
...
@@ -2,6 +2,7 @@
# Microsoft C 5.1 or later
# To use, do "make makefile.msc"
# To compile in small model, set below: MODEL=-AS
# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
...
...
Makefile.tc
浏览文件 @
25e53255
...
...
@@ -2,10 +2,11 @@
# TurboC 2.0
# To use, do "make -fmakefile.tc"
# To compile in small model, set below: MODEL=-ms
# WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example:
# -DMAX_WBITS=11 -D
DEF_WBITS=11 -D
MAX_MEM_LEVEL=3
# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
# If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below:
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
...
...
@@ -13,6 +14,7 @@
# ------------- Turbo C 2.0 -------------
MODEL
=
-ml
# CFLAGS=-O2 -G -Z $(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
CFLAGS
=
-O2
-G
-Z
$(MODEL)
CC
=
tcc
-I
\t
c
\i
nclude
LD
=
tcc
-L
\t
c
\l
ib
...
...
README
浏览文件 @
25e53255
zlib 0.94 is a beta version of a general purpose compression library.
Unless new bugs are found it will be released again as the first official
version (1.0). This version has no known bugs.
zlib 0.95 is a beta version of a general purpose compression library.
This should be the last version before the first official
version (1.0), so please test it now. (At least compile and run it with
"make test"). This version has no known bugs.
The data format used by the zlib library is described in the
files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
...
...
@@ -8,31 +9,29 @@ in ftp.uu.net:/pub/archiving/zip/doc.
All functions of the compression library are documented in the file
zlib.h. A usage example of the library is given in the file example.c
which also tests that the library is working correctly.
which also tests that the library is working correctly. Another
example is given in the file minigzip.c.
To compile all files and run the test program, just type: make test
(For MSDOS, use one of the special makefiles such as Makefile.msc.)
(For MSDOS, use one of the special makefiles such as Makefile.msc;
for VMS, use Make_vms.com or descrip.mms.)
To install the zlib library (libz.a) in /usr/local/lib, type: make install
To install in a different directory, use for example:
make install prefix=$HOME
This will install in $HOME/lib instead of /usr/local/lib.
The changes made in version 0.94 are documented in the file ChangeLog.
The main changes since 0.93 are:
- support MSDOS small and medium model
- fix deflate with flush (could sometimes generate bad output)
- fix deflateReset (zlib header was incorrectly suppressed)
- added support for VMS
- allow a compression level in gzopen()
- gzflush now calls fflush
- For deflate with flush, flush even if no more input is provided.
- rename libgz.a as libz.a
The changes made in version 0.95 are documented in the file ChangeLog.
The main changes since 0.94 are:
- fix MSDOS small and medium model (now easier to adapt to any compiler)
- inlined send_bits
- fix the final (:-) bug for deflate with flush (output was correct but
not completely flushed in rare occasions).
For MSDOS, the small and medium models
are supported only for
Microsoft C.
(
It should be easy to support them for Borland C also, but I don't have
a recent Borland compiler to test with.) The small model currently works
for Turbo/Borland C but only with reduced performance to avoid any far
allocation (tested with -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3).
For MSDOS, the small and medium models
have been tested only with
Microsoft C.
(
This should now work for Borland C also, but I don't have a recent Borland
compiler to test with.) The small model was tested with Turbo C but only with
reduced performance to avoid any far allocation; it was tested with
-DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
(C) 1995 Jean-loup Gailly and Mark Adler
...
...
deflate.c
浏览文件 @
25e53255
...
...
@@ -524,8 +524,8 @@ local int longest_match(s, cur_match)
* Try with and without -DUNALIGNED_OK to check.
*/
register
Bytef
*
strend
=
s
->
window
+
s
->
strstart
+
MAX_MATCH
-
1
;
register
ush
scan_start
=
*
(
ush
*
)
scan
;
register
ush
scan_end
=
*
(
ush
*
)(
scan
+
best_len
-
1
);
register
ush
scan_start
=
*
(
ush
f
*
)
scan
;
register
ush
scan_end
=
*
(
ush
f
*
)(
scan
+
best_len
-
1
);
#else
register
Bytef
*
strend
=
s
->
window
+
s
->
strstart
+
MAX_MATCH
;
register
Byte
scan_end1
=
scan
[
best_len
-
1
];
...
...
@@ -554,8 +554,8 @@ local int longest_match(s, cur_match)
/* This code assumes sizeof(unsigned short) == 2. Do not use
* UNALIGNED_OK if your compiler uses a different size.
*/
if
(
*
(
ush
*
)(
match
+
best_len
-
1
)
!=
scan_end
||
*
(
ush
*
)
match
!=
scan_start
)
continue
;
if
(
*
(
ush
f
*
)(
match
+
best_len
-
1
)
!=
scan_end
||
*
(
ush
f
*
)
match
!=
scan_start
)
continue
;
/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
...
...
@@ -569,10 +569,10 @@ local int longest_match(s, cur_match)
Assert
(
scan
[
2
]
==
match
[
2
],
"scan[2]?"
);
scan
++
,
match
++
;
do
{
}
while
(
*
(
ush
*
)(
scan
+=
2
)
==
*
(
ush
*
)(
match
+=
2
)
&&
*
(
ush
*
)(
scan
+=
2
)
==
*
(
ush
*
)(
match
+=
2
)
&&
*
(
ush
*
)(
scan
+=
2
)
==
*
(
ush
*
)(
match
+=
2
)
&&
*
(
ush
*
)(
scan
+=
2
)
==
*
(
ush
*
)(
match
+=
2
)
&&
}
while
(
*
(
ush
f
*
)(
scan
+=
2
)
==
*
(
ushf
*
)(
match
+=
2
)
&&
*
(
ush
f
*
)(
scan
+=
2
)
==
*
(
ushf
*
)(
match
+=
2
)
&&
*
(
ush
f
*
)(
scan
+=
2
)
==
*
(
ushf
*
)(
match
+=
2
)
&&
*
(
ush
f
*
)(
scan
+=
2
)
==
*
(
ushf
*
)(
match
+=
2
)
&&
scan
<
strend
);
/* The funny "do {}" generates better code on most compilers */
...
...
@@ -621,7 +621,7 @@ local int longest_match(s, cur_match)
best_len
=
len
;
if
(
len
>=
s
->
nice_match
)
break
;
#ifdef UNALIGNED_OK
scan_end
=
*
(
ush
*
)(
scan
+
best_len
-
1
);
scan_end
=
*
(
ush
f
*
)(
scan
+
best_len
-
1
);
#else
scan_end1
=
scan
[
best_len
-
1
];
scan_end
=
scan
[
best_len
];
...
...
deflate.h
浏览文件 @
25e53255
...
...
@@ -233,6 +233,7 @@ typedef struct internal_state {
ulg
static_len
;
/* bit length of current block with static trees */
ulg
compressed_len
;
/* total bit length of compressed file */
uInt
matches
;
/* number of string matches in current block */
int
last_eob_len
;
/* bit length of EOB code for last block */
#ifdef DEBUG
ulg
bits_sent
;
/* bit length of the compressed data */
...
...
example.c
浏览文件 @
25e53255
...
...
@@ -277,7 +277,7 @@ int main(argc, argv)
fprintf
(
stderr
,
"incompatible zlib version
\n
"
);
exit
(
1
);
}
else
if
(
z
strcmp
(
zlib_version
,
ZLIB_VERSION
)
!=
0
)
{
}
else
if
(
strcmp
(
zlib_version
,
ZLIB_VERSION
)
!=
0
)
{
fprintf
(
stderr
,
"warning: different zlib version
\n
"
);
}
test_compress
();
...
...
gzio.c
浏览文件 @
25e53255
...
...
@@ -234,7 +234,7 @@ gzFile gzdopen (fd, mode)
*/
int
gzread
(
file
,
buf
,
len
)
gzFile
file
;
void
n
p
buf
;
voidp
buf
;
unsigned
len
;
{
gz_stream
*
s
=
(
gz_stream
*
)
file
;
...
...
@@ -292,7 +292,7 @@ int gzread (file, buf, len)
*/
int
gzwrite
(
file
,
buf
,
len
)
gzFile
file
;
void
n
p
buf
;
voidp
buf
;
unsigned
len
;
{
gz_stream
*
s
=
(
gz_stream
*
)
file
;
...
...
inftrees.c
浏览文件 @
25e53255
...
...
@@ -25,14 +25,14 @@ local int huft_build OF((
uIntf
*
,
/* maximum lookup bits (returns actual) */
z_stream
*
));
/* for zalloc function */
local
voidp
falloc
OF
((
voidp
,
/* opaque pointer (not used) */
local
voidp
f
falloc
OF
((
voidp
f
,
/* opaque pointer (not used) */
uInt
,
/* number of items */
uInt
));
/* size of item */
local
void
ffree
OF
((
voidp
q
,
/* opaque pointer (not used) */
voidp
p
));
/* what to free (not used) */
voidp
f
q
,
/* opaque pointer (not used) */
voidp
f
p
));
/* what to free (not used) */
/* Tables for deflate from PKZIP's appnote.txt. */
local
uInt
cplens
[]
=
{
/* Copy lengths for literal codes 257..285 */
...
...
@@ -377,8 +377,8 @@ local inflate_huft *fixed_tl;
local
inflate_huft
*
fixed_td
;
local
voidp
falloc
(
q
,
n
,
s
)
voidp
q
;
/* opaque pointer (not used) */
local
voidp
f
falloc
(
q
,
n
,
s
)
voidp
f
q
;
/* opaque pointer (not used) */
uInt
n
;
/* number of items */
uInt
s
;
/* size of item */
{
...
...
@@ -386,13 +386,13 @@ uInt s; /* size of item */
"inflate_trees falloc overflow"
);
if
(
q
)
s
++
;
/* to make some compilers happy */
fixed_left
-=
n
;
return
(
voidp
)(
fixed_mem
+
fixed_left
);
return
(
voidp
f
)(
fixed_mem
+
fixed_left
);
}
local
void
ffree
(
q
,
p
)
voidp
q
;
voidp
p
;
voidp
f
q
;
voidp
f
p
;
{
Assert
(
0
,
"inflate_trees ffree called!"
);
if
(
q
)
q
=
p
;
/* to make some compilers happy */
...
...
trees.c
浏览文件 @
25e53255
...
...
@@ -143,9 +143,9 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
local
void
compress_block
OF
((
deflate_state
*
s
,
ct_data
*
ltree
,
ct_data
*
dtree
));
local
void
set_data_type
OF
((
deflate_state
*
s
));
local
void
send_bits
OF
((
deflate_state
*
s
,
int
value
,
int
length
));
local
unsigned
bi_reverse
OF
((
unsigned
value
,
int
length
));
local
void
bi_windup
OF
((
deflate_state
*
s
));
local
void
bi_flush
OF
((
deflate_state
*
s
));
local
void
copy_block
OF
((
deflate_state
*
s
,
charf
*
buf
,
unsigned
len
,
int
header
));
...
...
@@ -166,6 +166,63 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
* used.
*/
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
#ifdef DEBUG
local
void
send_bits
OF
((
deflate_state
*
s
,
int
value
,
int
length
));
local
void
send_bits
(
s
,
value
,
length
)
deflate_state
*
s
;
int
value
;
/* value to send */
int
length
;
/* number of bits */
{
Tracev
((
stderr
,
" l %2d v %4x "
,
length
,
value
));
Assert
(
length
>
0
&&
length
<=
15
,
"invalid length"
);
s
->
bits_sent
+=
(
ulg
)
length
;
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
* unused bits in value.
*/
if
(
s
->
bi_valid
>
(
int
)
Buf_size
-
length
)
{
s
->
bi_buf
|=
(
value
<<
s
->
bi_valid
);
put_short
(
s
,
s
->
bi_buf
);
s
->
bi_buf
=
(
ush
)
value
>>
(
Buf_size
-
s
->
bi_valid
);
s
->
bi_valid
+=
length
-
Buf_size
;
}
else
{
s
->
bi_buf
|=
value
<<
s
->
bi_valid
;
s
->
bi_valid
+=
length
;
}
}
#else
/* !DEBUG */
#define send_bits(s, value, length) \
{ int len = length;\
if (s->bi_valid > (int)Buf_size - len) {\
int val = value;\
s->bi_buf |= (val << s->bi_valid);\
put_short(s, s->bi_buf);\
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
s->bi_valid += len - Buf_size;\
} else {\
s->bi_buf |= (value) << s->bi_valid;\
s->bi_valid += len;\
}\
}
#endif
/* DEBUG */
#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
...
...
@@ -259,6 +316,7 @@ void ct_init(s)
s
->
bi_buf
=
0
;
s
->
bi_valid
=
0
;
s
->
last_eob_len
=
8
;
/* enough lookahead for inflate */
#ifdef DEBUG
s
->
bits_sent
=
0L
;
#endif
...
...
@@ -739,7 +797,12 @@ void ct_stored_block(s, buf, stored_len, eof)
}
/* ===========================================================================
* Send one empty static block to give enough lookahead for inflate
* Send one empty static block to give enough lookahead for inflate.
* This takes 10 bits, of which 7 may remain in the bit buffer.
* The current inflate code requires 9 bits of lookahead. If the EOB
* code for the previous block was coded on 5 bits or less, inflate
* may have only 5+3 bits of lookahead to decode this EOB.
* (There are no problems if the previous block is stored or fixed.)
*/
void
ct_align
(
s
)
deflate_state
*
s
;
...
...
@@ -747,6 +810,18 @@ void ct_align(s)
send_bits
(
s
,
STATIC_TREES
<<
1
,
3
);
send_code
(
s
,
END_BLOCK
,
static_ltree
);
s
->
compressed_len
+=
10L
;
/* 3 for block type, 7 for EOB */
bi_flush
(
s
);
/* Of the 10 bits for the empty block, we have already sent
* (10 - bi_valid) bits. The lookahead for the EOB of the previous
* block was thus its length plus what we have just sent.
*/
if
(
s
->
last_eob_len
+
10
-
s
->
bi_valid
<
9
)
{
send_bits
(
s
,
STATIC_TREES
<<
1
,
3
);
send_code
(
s
,
END_BLOCK
,
static_ltree
);
s
->
compressed_len
+=
10L
;
bi_flush
(
s
);
}
s
->
last_eob_len
=
7
;
}
/* ===========================================================================
...
...
@@ -950,6 +1025,7 @@ local void compress_block(s, ltree, dtree)
}
while
(
lx
<
s
->
last_lit
);
send_code
(
s
,
END_BLOCK
,
ltree
);
s
->
last_eob_len
=
ltree
[
END_BLOCK
].
Len
;
}
/* ===========================================================================
...
...
@@ -970,44 +1046,6 @@ local void set_data_type(s)
s
->
data_type
=
(
Byte
)(
bin_freq
>
(
ascii_freq
>>
2
)
?
BINARY
:
ASCII
);
}
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
local
void
send_bits
(
s
,
value
,
length
)
deflate_state
*
s
;
int
value
;
/* value to send */
int
length
;
/* number of bits */
{
#ifdef DEBUG
Tracev
((
stderr
,
" l %2d v %4x "
,
length
,
value
));
Assert
(
length
>
0
&&
length
<=
15
,
"invalid length"
);
s
->
bits_sent
+=
(
ulg
)
length
;
#endif
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
* unused bits in value.
*/
if
(
s
->
bi_valid
>
(
int
)
Buf_size
-
length
)
{
s
->
bi_buf
|=
(
value
<<
s
->
bi_valid
);
put_short
(
s
,
s
->
bi_buf
);
s
->
bi_buf
=
(
ush
)
value
>>
(
Buf_size
-
s
->
bi_valid
);
s
->
bi_valid
+=
length
-
Buf_size
;
}
else
{
s
->
bi_buf
|=
value
<<
s
->
bi_valid
;
s
->
bi_valid
+=
length
;
}
}
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
...
...
@@ -1026,7 +1064,24 @@ local unsigned bi_reverse(code, len)
}
/* ===========================================================================
* Write out any remaining bits in an incomplete byte.
* Flush the bit buffer, keeping at most 7 bits in it.
*/
local
void
bi_flush
(
s
)
deflate_state
*
s
;
{
if
(
s
->
bi_valid
==
16
)
{
put_short
(
s
,
s
->
bi_buf
);
s
->
bi_buf
=
0
;
s
->
bi_valid
=
0
;
}
else
if
(
s
->
bi_valid
>=
8
)
{
put_byte
(
s
,
(
Byte
)
s
->
bi_buf
);
s
->
bi_buf
>>=
8
;
s
->
bi_valid
-=
8
;
}
}
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
local
void
bi_windup
(
s
)
deflate_state
*
s
;
...
...
@@ -1053,7 +1108,8 @@ local void copy_block(s, buf, len, header)
unsigned
len
;
/* its length */
int
header
;
/* true if block header must be written */
{
bi_windup
(
s
);
/* align on byte boundary */
bi_windup
(
s
);
/* align on byte boundary */
s
->
last_eob_len
=
8
;
/* enough lookahead for inflate */
if
(
header
)
{
put_short
(
s
,
(
ush
)
len
);
...
...
zconf.h
浏览文件 @
25e53255
...
...
@@ -85,37 +85,42 @@
# endif
#endif
#if defined(M_I86SM) || defined(M_I86MM)
/* model independent MSC functions */
# define zstrcpy _fstrcpy
# define zstrcat _fstrcat
# define zstrlen _fstrlen
# define zstrcmp _fstrcmp
# define FAR __far
#else
# define zstrcpy strcpy
# define zstrcat strcat
# define zstrlen strlen
# define zstrcmp strcmp
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# ifdef _MSC_VER
# define FAR __far
# else
# define FAR far
# endif
#endif
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# define FAR __far
/* completely untested, just a best guess */
#endif
#ifndef FAR
# define FAR
#endif
typedef
unsigned
char
Byte
;
/* 8 bits */
typedef
unsigned
int
uInt
;
/* 16 bits or more */
typedef
unsigned
long
uLong
;
/* 32 bits or more */
typedef
Byte
FAR
Bytef
;
typedef
char
FAR
charf
;
typedef
Byte
FAR
Bytef
;
typedef
char
FAR
charf
;
typedef
int
FAR
intf
;
typedef
uInt
FAR
uIntf
;
typedef
uLong
FAR
uLongf
;
#ifdef STDC
typedef
void
FAR
*
voidp
;
typedef
void
*
void
n
p
;
typedef
void
FAR
*
voidp
f
;
typedef
void
*
voidp
;
#else
typedef
Byte
FAR
*
voidp
;
typedef
Byte
*
void
n
p
;
typedef
Byte
FAR
*
voidp
f
;
typedef
Byte
*
voidp
;
#endif
#endif
/* _ZCONF_H */
zlib.h
浏览文件 @
25e53255
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 0.9
4, Aug 13
th, 1995.
version 0.9
5, Aug 16
th, 1995.
Copyright (C) 1995 Jean-loup Gailly and Mark Adler
...
...
@@ -28,7 +28,7 @@
#include "zconf.h"
#define ZLIB_VERSION "0.9
4
"
#define ZLIB_VERSION "0.9
5
"
/*
The 'zlib' compression library provides in-memory compression and
...
...
@@ -49,8 +49,8 @@
(providing more output space) before each call.
*/
typedef
voidp
(
*
alloc_func
)
OF
((
voidp
opaque
,
uInt
items
,
uInt
size
));
typedef
void
(
*
free_func
)
OF
((
voidp
opaque
,
voidp
address
));
typedef
voidp
f
(
*
alloc_func
)
OF
((
voidpf
opaque
,
uInt
items
,
uInt
size
));
typedef
void
(
*
free_func
)
OF
((
voidpf
opaque
,
voidpf
address
));
struct
internal_state
;
...
...
@@ -510,7 +510,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen,
*/
typedef
void
n
p
gzFile
;
typedef
voidp
gzFile
;
extern
gzFile
gzopen
OF
((
char
*
path
,
char
*
mode
));
/*
...
...
@@ -533,7 +533,7 @@ extern gzFile gzdopen OF((int fd, char *mode));
the (de)compression state.
*/
extern
int
gzread
OF
((
gzFile
file
,
void
n
p
buf
,
unsigned
len
));
extern
int
gzread
OF
((
gzFile
file
,
voidp
buf
,
unsigned
len
));
/*
Reads the given number of uncompressed bytes from the compressed file.
If the input file was not in gzip format, gzread copies the given number
...
...
@@ -541,7 +541,7 @@ extern int gzread OF((gzFile file, voidnp buf, unsigned len));
gzread returns the number of uncompressed bytes actually read (0 for
end of file, -1 for error). */
extern
int
gzwrite
OF
((
gzFile
file
,
void
n
p
buf
,
unsigned
len
));
extern
int
gzwrite
OF
((
gzFile
file
,
voidp
buf
,
unsigned
len
));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes actually written
...
...
zutil.c
浏览文件 @
25e53255
...
...
@@ -38,8 +38,8 @@ void z_error (m)
#ifndef HAVE_MEMCPY
void
zmemcpy
(
dest
,
source
,
len
)
Byte
*
dest
;
Byte
*
source
;
Byte
f
*
dest
;
Byte
f
*
source
;
uInt
len
;
{
if
(
len
==
0
)
return
;
...
...
@@ -49,7 +49,7 @@ void zmemcpy(dest, source, len)
}
void
zmemzero
(
dest
,
len
)
Byte
*
dest
;
Byte
f
*
dest
;
uInt
len
;
{
if
(
len
==
0
)
return
;
...
...
@@ -59,8 +59,10 @@ void zmemzero(dest, len)
}
#endif
#if defined(__TURBOC__) && !defined(__SMALL__)
#if defined( __TURBOC__) && !defined(__SMALL__) && !defined(__MEDIUM__)
/* Small and medium model are for now limited to near allocation with
* reduced MAX_WBITS and MAX_MEM_LEVEL
*/
# define MY_ZCALLOC
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
...
...
@@ -75,8 +77,8 @@ void zmemzero(dest, len)
local
int
next_ptr
=
0
;
typedef
struct
ptr_table_s
{
voidp
org_ptr
;
voidp
new_ptr
;
voidp
f
org_ptr
;
voidp
f
new_ptr
;
}
ptr_table
;
local
ptr_table
table
[
MAX_PTR
];
...
...
@@ -87,9 +89,9 @@ local ptr_table table[MAX_PTR];
* a protected system like OS/2. Use Microsoft C instead.
*/
voidp
zcalloc
(
voidp
opaque
,
unsigned
items
,
unsigned
size
)
voidp
f
zcalloc
(
voidpf
opaque
,
unsigned
items
,
unsigned
size
)
{
voidp
buf
=
opaque
;
/* just to make some compilers happy */
voidp
f
buf
=
opaque
;
/* just to make some compilers happy */
ulg
bsize
=
(
ulg
)
items
*
size
;
if
(
bsize
<
65536L
)
{
...
...
@@ -108,7 +110,7 @@ voidp zcalloc (voidp opaque, unsigned items, unsigned size)
return
buf
;
}
void
zcfree
(
voidp
opaque
,
voidp
ptr
)
void
zcfree
(
voidp
f
opaque
,
voidpf
ptr
)
{
int
n
;
if
(
*
(
ush
*
)
&
ptr
!=
0
)
{
/* object < 64K */
...
...
@@ -131,7 +133,8 @@ void zcfree (voidp opaque, voidp ptr)
}
#endif
/* __TURBOC__ */
#if defined(MSDOS) && !defined(__TURBOC__)
/* MSC */
#if defined(M_I86SM)||defined(M_I86MM)||defined(M_I86CM)||defined(M_I86LM)
/* Microsoft C */
# define MY_ZCALLOC
...
...
@@ -140,13 +143,13 @@ void zcfree (voidp opaque, voidp ptr)
# define _hfree hfree
#endif
voidp
zcalloc
(
voidp
opaque
,
unsigned
items
,
unsigned
size
)
voidp
f
zcalloc
(
voidpf
opaque
,
unsigned
items
,
unsigned
size
)
{
if
(
opaque
)
opaque
=
0
;
/* to make compiler happy */
return
_halloc
((
long
)
items
,
size
);
}
void
zcfree
(
voidp
opaque
,
voidp
ptr
)
void
zcfree
(
voidp
f
opaque
,
voidpf
ptr
)
{
if
(
opaque
)
opaque
=
0
;
/* to make compiler happy */
_hfree
(
ptr
);
...
...
@@ -158,21 +161,21 @@ void zcfree (voidp opaque, voidp ptr)
#ifndef MY_ZCALLOC
/* Any system without a special alloc function */
#ifndef __GO32__
extern
voidp
calloc
OF
((
uInt
items
,
uInt
size
));
extern
void
free
OF
((
voidp
ptr
));
extern
voidp
calloc
OF
((
uInt
items
,
uInt
size
));
extern
void
free
OF
((
voidpf
ptr
));
#endif
voidp
zcalloc
(
opaque
,
items
,
size
)
voidp
opaque
;
voidp
f
zcalloc
(
opaque
,
items
,
size
)
voidp
f
opaque
;
unsigned
items
;
unsigned
size
;
{
return
calloc
(
items
,
size
);
return
(
voidpf
)
calloc
(
items
,
size
);
}
void
zcfree
(
opaque
,
ptr
)
voidp
opaque
;
voidp
ptr
;
voidp
f
opaque
;
voidp
f
ptr
;
{
free
(
ptr
);
}
...
...
zutil.h
浏览文件 @
25e53255
...
...
@@ -46,7 +46,7 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
#define DEFLATED 8
#ifndef DEF_WBITS
# define DEF_WBITS
15
# define DEF_WBITS
MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
...
...
@@ -72,7 +72,7 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
# define OS_CODE 0x00
# ifdef __TURBOC__
# include <alloc.h>
# else
/* MSC */
# else
/* MSC
or DJGPP
*/
# include <malloc.h>
# endif
#endif
...
...
@@ -130,23 +130,29 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
# define zstrerror(errnum) ""
#endif
#if defined(pyr) && !defined(NO_MEMCPY)
#if defined(pyr)
# define NO_MEMCPY
#endif
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# if
def M_I86MM
/* MSC
medium model */
# if
defined(M_I86SM) || defined(M_I86MM)
/* MSC small or
medium model */
# define zmemcpy _fmemcpy
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# else
# define zmemcpy memcpy
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern
void
zmemcpy
OF
((
Byte
*
dest
,
Byte
*
source
,
uInt
len
));
extern
void
zmemzero
OF
((
Byte
*
dest
,
uInt
len
));
extern
void
zmemcpy
OF
((
Byte
f
*
dest
,
Bytef
*
source
,
uInt
len
));
extern
void
zmemzero
OF
((
Byte
f
*
dest
,
uInt
len
));
#endif
/* Diagnostic functions */
...
...
@@ -175,12 +181,12 @@ typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
extern
void
z_error
OF
((
char
*
m
));
voidp
zcalloc
OF
((
voidp
opaque
,
unsigned
items
,
unsigned
size
));
void
zcfree
OF
((
voidp
opaque
,
voidp
ptr
));
voidp
f
zcalloc
OF
((
voidpf
opaque
,
unsigned
items
,
unsigned
size
));
void
zcfree
OF
((
voidpf
opaque
,
voidpf
ptr
));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidp)(addr))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidp
f
)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif
/* _Z_UTIL_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录