Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e0db4b86
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
大约 1 年 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0db4b86
编写于
4月 28, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[buffer] More error handling
Should be all set now.
上级
15c57e04
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
19 deletion
+43
-19
src/hb-buffer-private.hh
src/hb-buffer-private.hh
+1
-1
src/hb-buffer.cc
src/hb-buffer.cc
+42
-18
未找到文件。
src/hb-buffer-private.hh
浏览文件 @
e0db4b86
...
...
@@ -95,9 +95,9 @@ struct _hb_buffer_t {
/* Buffer contents */
bool
in_error
;
/* Allocation failed */
bool
have_output
;
/* Whether we have an output buffer going on */
bool
have_positions
;
/* Whether we have positions */
bool
in_error
;
/* Allocation failed */
unsigned
int
i
;
/* Cursor into ->info and ->pos arrays */
unsigned
int
len
;
/* Length of ->info and ->pos arrays */
...
...
src/hb-buffer.cc
浏览文件 @
e0db4b86
...
...
@@ -43,6 +43,10 @@ static hb_buffer_t _hb_buffer_nil = {
HB_SCRIPT_INVALID
,
NULL
,
},
TRUE
,
/* in_error */
TRUE
,
/* have_output */
TRUE
/* have_positions */
};
/* Here is how the buffer works internally:
...
...
@@ -71,26 +75,26 @@ _hb_buffer_enlarge (hb_buffer_t *buffer, unsigned int size)
return
FALSE
;
unsigned
int
new_allocated
=
buffer
->
allocated
;
hb_glyph_position_t
*
new_pos
;
hb_glyph_info_t
*
new_info
;
bool
separate_out
;
hb_glyph_position_t
*
new_pos
=
NULL
;
hb_glyph_info_t
*
new_info
=
NULL
;
bool
overflows
=
FALSE
;
bool
separate_out
=
buffer
->
out_info
!=
buffer
->
info
;
separate_out
=
buffer
->
out_info
!=
buffer
->
info
;
if
(
unlikely
(
size
>
((
unsigned
int
)
-
1
)
/
2
))
goto
done
;
while
(
size
>
new_allocated
)
new_allocated
+=
(
new_allocated
>>
1
)
+
32
;
ASSERT_STATIC
(
sizeof
(
buffer
->
info
[
0
])
==
sizeof
(
buffer
->
pos
[
0
]));
bool
overflows
=
new_allocated
>=
((
unsigned
int
)
-
1
)
/
sizeof
(
buffer
->
info
[
0
]);
overflows
=
new_allocated
>=
((
unsigned
int
)
-
1
)
/
sizeof
(
buffer
->
info
[
0
]);
if
(
unlikely
(
overflows
))
goto
done
;
if
(
unlikely
(
overflows
))
{
new_pos
=
NULL
;
new_info
=
NULL
;
}
else
{
new_pos
=
(
hb_glyph_position_t
*
)
realloc
(
buffer
->
pos
,
new_allocated
*
sizeof
(
buffer
->
pos
[
0
]));
new_info
=
(
hb_glyph_info_t
*
)
realloc
(
buffer
->
info
,
new_allocated
*
sizeof
(
buffer
->
info
[
0
]));
}
new_pos
=
(
hb_glyph_position_t
*
)
realloc
(
buffer
->
pos
,
new_allocated
*
sizeof
(
buffer
->
pos
[
0
]));
new_info
=
(
hb_glyph_info_t
*
)
realloc
(
buffer
->
info
,
new_allocated
*
sizeof
(
buffer
->
info
[
0
]));
done:
if
(
unlikely
(
!
new_pos
||
!
new_info
))
buffer
->
in_error
=
TRUE
;
...
...
@@ -116,7 +120,7 @@ _hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
static
inline
hb_bool_t
_hb_buffer_ensure_separate
(
hb_buffer_t
*
buffer
,
unsigned
int
size
)
{
if
(
unlikely
(
!
_hb_buffer_ensure
(
buffer
,
size
)))
return
FALSE
;
if
(
unlikely
(
!
size
||
!
_hb_buffer_ensure
(
buffer
,
size
)))
return
FALSE
;
if
(
buffer
->
out_info
==
buffer
->
info
)
{
...
...
@@ -188,8 +192,11 @@ void
hb_buffer_set_unicode_funcs
(
hb_buffer_t
*
buffer
,
hb_unicode_funcs_t
*
unicode
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
if
(
!
unicode
)
unicode
=
&
_hb_unicode_funcs_default
;
unicode
=
_hb_buffer_nil
.
unicode
;
hb_unicode_funcs_reference
(
unicode
);
hb_unicode_funcs_destroy
(
buffer
->
unicode
);
...
...
@@ -207,6 +214,9 @@ hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t
direction
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
buffer
->
props
.
direction
=
direction
;
}
...
...
@@ -220,6 +230,9 @@ void
hb_buffer_set_script
(
hb_buffer_t
*
buffer
,
hb_script_t
script
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
buffer
->
props
.
script
=
script
;
}
...
...
@@ -233,6 +246,9 @@ void
hb_buffer_set_language
(
hb_buffer_t
*
buffer
,
hb_language_t
language
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
buffer
->
props
.
language
=
language
;
}
...
...
@@ -246,14 +262,17 @@ hb_buffer_get_language (hb_buffer_t *buffer)
void
hb_buffer_reset
(
hb_buffer_t
*
buffer
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
hb_unicode_funcs_destroy
(
buffer
->
unicode
);
buffer
->
unicode
=
_hb_buffer_nil
.
unicode
;
buffer
->
props
=
_hb_buffer_nil
.
props
;
buffer
->
in_error
=
FALSE
;
buffer
->
have_output
=
FALSE
;
buffer
->
have_positions
=
FALSE
;
buffer
->
in_error
=
FALSE
;
buffer
->
i
=
0
;
buffer
->
len
=
0
;
...
...
@@ -301,6 +320,9 @@ hb_buffer_add (hb_buffer_t *buffer,
void
_hb_buffer_clear_output
(
hb_buffer_t
*
buffer
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
buffer
->
have_output
=
TRUE
;
buffer
->
have_positions
=
FALSE
;
...
...
@@ -311,6 +333,9 @@ _hb_buffer_clear_output (hb_buffer_t *buffer)
void
_hb_buffer_clear_positions
(
hb_buffer_t
*
buffer
)
{
if
(
unlikely
(
hb_object_is_inert
(
buffer
)))
return
;
buffer
->
have_output
=
FALSE
;
buffer
->
have_positions
=
TRUE
;
...
...
@@ -320,12 +345,10 @@ _hb_buffer_clear_positions (hb_buffer_t *buffer)
void
_hb_buffer_swap
(
hb_buffer_t
*
buffer
)
{
unsigned
int
tmp
;
if
(
unlikely
(
buffer
->
in_error
))
return
;
assert
(
buffer
->
have_output
);
if
(
unlikely
(
buffer
->
in_error
))
return
;
if
(
buffer
->
out_info
!=
buffer
->
info
)
{
hb_glyph_info_t
*
tmp_string
;
...
...
@@ -335,6 +358,7 @@ _hb_buffer_swap (hb_buffer_t *buffer)
buffer
->
pos
=
(
hb_glyph_position_t
*
)
buffer
->
out_info
;
}
unsigned
int
tmp
;
tmp
=
buffer
->
len
;
buffer
->
len
=
buffer
->
out_len
;
buffer
->
out_len
=
tmp
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录