Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Zlib
提交
95698093
T
Third Party Zlib
项目概览
OpenHarmony
/
Third Party Zlib
接近 2 年 前同步成功
通知
18
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看板
提交
95698093
编写于
7月 05, 2015
作者:
M
Mark Adler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve speed of gzprintf() in transparent mode.
上级
8a979f6c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
51 deletion
+70
-51
gzguts.h
gzguts.h
+1
-1
gzlib.c
gzlib.c
+2
-0
gzwrite.c
gzwrite.c
+64
-46
zlib.h
zlib.h
+3
-4
未找到文件。
gzguts.h
浏览文件 @
95698093
...
...
@@ -170,7 +170,7 @@ typedef struct {
char
*
path
;
/* path or fd for error messages */
unsigned
size
;
/* buffer size, zero if not allocated yet */
unsigned
want
;
/* requested buffer size, default is GZBUFSIZE */
unsigned
char
*
in
;
/* input buffer */
unsigned
char
*
in
;
/* input buffer
(double-sized when writing)
*/
unsigned
char
*
out
;
/* output buffer (double-sized when reading) */
int
direct
;
/* 0 if processing gzip, 1 if transparent */
/* just for reading */
...
...
gzlib.c
浏览文件 @
95698093
...
...
@@ -331,6 +331,8 @@ int ZEXPORT gzbuffer(file, size)
return
-
1
;
/* check and set requested size */
if
((
size
<<
1
)
<
size
)
return
-
1
;
/* need to be able to double it */
if
(
size
<
2
)
size
=
2
;
/* need two bytes to check magic header */
state
->
want
=
size
;
...
...
gzwrite.c
浏览文件 @
95698093
...
...
@@ -18,8 +18,8 @@ local int gz_init(state)
int
ret
;
z_streamp
strm
=
&
(
state
->
strm
);
/* allocate input buffer */
state
->
in
=
(
unsigned
char
*
)
malloc
(
state
->
want
);
/* allocate input buffer
(double size for gzprintf)
*/
state
->
in
=
(
unsigned
char
*
)
malloc
(
state
->
want
<<
1
);
if
(
state
->
in
==
NULL
)
{
gz_error
(
state
,
Z_MEM_ERROR
,
"out of memory"
);
return
-
1
;
...
...
@@ -309,7 +309,8 @@ int ZEXPORT gzputs(file, str)
/* -- see zlib.h -- */
int
ZEXPORTVA
gzvprintf
(
gzFile
file
,
const
char
*
format
,
va_list
va
)
{
int
size
,
len
;
unsigned
len
,
left
;
char
*
next
;
gz_statep
state
;
z_streamp
strm
;
...
...
@@ -334,39 +335,47 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
return
0
;
}
/*
consume whatever's left in the input buffer */
if
(
strm
->
avail_in
&&
gz_comp
(
state
,
Z_NO_FLUSH
)
==
-
1
)
return
0
;
/* do the printf() into the input buffer, put length in len */
size
=
(
int
)(
state
->
size
);
state
->
in
[
size
-
1
]
=
0
;
/*
do the printf() into the input buffer, put length in len -- the input
buffer is double-sized just for this function, so there is guaranteed to
be state->size bytes available after the current contents */
if
(
strm
->
avail_in
==
0
)
strm
->
next_in
=
state
->
in
;
next
=
(
char
*
)(
strm
->
next_in
+
strm
->
avail_in
);
next
[
state
->
size
-
1
]
=
0
;
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
(
void
)
vsprintf
(
(
char
*
)(
state
->
in
)
,
format
,
va
);
for
(
len
=
0
;
len
<
size
;
len
++
)
if
(
state
->
in
[
len
]
==
0
)
break
;
(
void
)
vsprintf
(
next
,
format
,
va
);
for
(
len
=
0
;
len
<
s
tate
->
s
ize
;
len
++
)
if
(
next
[
len
]
==
0
)
break
;
# else
len
=
vsprintf
(
(
char
*
)(
state
->
in
)
,
format
,
va
);
len
=
vsprintf
(
next
,
format
,
va
);
# endif
#else
# ifdef HAS_vsnprintf_void
(
void
)
vsnprintf
(
(
char
*
)(
state
->
in
),
size
,
format
,
va
);
len
=
strlen
(
(
char
*
)(
state
->
in
)
);
(
void
)
vsnprintf
(
next
,
state
->
size
,
format
,
va
);
len
=
strlen
(
next
);
# else
len
=
vsnprintf
(
(
char
*
)(
state
->
in
),
size
,
format
,
va
);
len
=
vsnprintf
(
next
,
state
->
size
,
format
,
va
);
# endif
#endif
/* check that printf() results fit in buffer */
if
(
len
<=
0
||
len
>=
(
int
)
size
||
state
->
in
[
size
-
1
]
!=
0
)
if
(
len
==
0
||
len
>=
state
->
size
||
next
[
state
->
size
-
1
]
!=
0
)
return
0
;
/* update buffer and position, defer compression until needed */
strm
->
avail_in
=
(
unsigned
)
len
;
strm
->
next_in
=
state
->
in
;
/* update buffer and position, compress first half if past that */
strm
->
avail_in
+=
len
;
state
->
x
.
pos
+=
len
;
return
len
;
if
(
strm
->
avail_in
>=
state
->
size
)
{
left
=
strm
->
avail_in
-
state
->
size
;
strm
->
avail_in
=
state
->
size
;
if
(
gz_comp
(
state
,
Z_NO_FLUSH
)
==
-
1
)
return
0
;
memcpy
(
state
->
in
,
state
->
in
+
state
->
size
,
left
);
strm
->
next_in
=
state
->
in
;
strm
->
avail_in
=
left
;
}
return
(
int
)
len
;
}
int
ZEXPORTVA
gzprintf
(
gzFile
file
,
const
char
*
format
,
...)
...
...
@@ -390,7 +399,8 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
int
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
;
{
int
size
,
len
;
unsigned
len
,
left
;
char
*
next
;
gz_statep
state
;
z_streamp
strm
;
...
...
@@ -419,44 +429,52 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
return
0
;
}
/*
consume whatever's left in the input buffer */
if
(
strm
->
avail_in
&&
gz_comp
(
state
,
Z_NO_FLUSH
)
==
-
1
)
return
0
;
/* do the printf() into the input buffer, put length in len */
size
=
(
int
)(
state
->
size
);
state
->
in
[
size
-
1
]
=
0
;
/*
do the printf() into the input buffer, put length in len -- the input
buffer is double-sized just for this function, so there is guaranteed to
be state->size bytes available after the current contents */
if
(
strm
->
avail_in
==
0
)
strm
->
next_in
=
state
->
in
;
next
=
(
char
*
)(
strm
->
next_in
+
strm
->
avail_in
);
next
[
state
->
size
-
1
]
=
0
;
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
sprintf
(
(
char
*
)(
state
->
in
),
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a
9
,
a10
,
a11
,
a12
,
a
13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
sprintf
(
next
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
for
(
len
=
0
;
len
<
size
;
len
++
)
if
(
state
->
in
[
len
]
==
0
)
break
;
if
(
next
[
len
]
==
0
)
break
;
# else
len
=
sprintf
(
(
char
*
)(
state
->
in
),
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a
9
,
a10
,
a11
,
a
12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
len
=
sprintf
(
next
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
# endif
#else
# ifdef HAS_snprintf_void
snprintf
(
(
char
*
)(
state
->
in
),
size
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a
9
,
a
10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
len
=
strlen
(
(
char
*
)(
state
->
in
)
);
snprintf
(
next
,
state
->
size
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
len
=
strlen
(
next
);
# else
len
=
snprintf
((
char
*
)(
state
->
in
),
size
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
len
=
snprintf
(
next
,
state
->
size
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
a11
,
a12
,
a13
,
a14
,
a15
,
a16
,
a17
,
a18
,
a19
,
a20
);
# endif
#endif
/* check that printf() results fit in buffer */
if
(
len
<=
0
||
len
>=
(
int
)
size
||
state
->
in
[
size
-
1
]
!=
0
)
if
(
len
==
0
||
len
>=
state
->
size
||
next
[
state
->
size
-
1
]
!=
0
)
return
0
;
/* update buffer and position, defer compression until needed */
strm
->
avail_in
=
(
unsigned
)
len
;
strm
->
next_in
=
state
->
in
;
/* update buffer and position, compress first half if past that */
strm
->
avail_in
+=
len
;
state
->
x
.
pos
+=
len
;
return
len
;
if
(
strm
->
avail_in
>=
state
->
size
)
{
left
=
strm
->
avail_in
-
state
->
size
;
strm
->
avail_in
=
state
->
size
;
if
(
gz_comp
(
state
,
Z_NO_FLUSH
)
==
-
1
)
return
0
;
memcpy
(
state
->
in
,
state
->
in
+
state
->
size
,
left
);
strm
->
next_in
=
state
->
in
;
strm
->
avail_in
=
left
;
}
return
(
int
)
len
;
}
#endif
...
...
zlib.h
浏览文件 @
95698093
...
...
@@ -1291,10 +1291,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
default buffer size is 8192 bytes. This function must be called after
gzopen() or gzdopen(), and before any other calls that read or write the
file. The buffer memory allocation is always deferred to the first read or
write. Two buffers are allocated, either both of the specified size when
writing, or one of the specified size and the other twice that size when
reading. A larger buffer size of, for example, 64K or 128K bytes will
noticeably increase the speed of decompression (reading).
write. Three times that size in buffer space is allocated. A larger buffer
size of, for example, 64K or 128K bytes will noticeably increase the speed
of decompression (reading).
The new buffer size also affects the maximum length for gzprintf().
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录