Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-06 13:17:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c38a54578040cebe22ab5b666e923d2f44c67c44
c38a5457
1 parent
fd0c85b3
reserach st: refine key.c
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
37 行增加
和
36 行删除
trunk/research/st/key.c
trunk/research/st/key.c
查看文件 @
c38a545
...
...
@@ -56,51 +56,52 @@ static int key_max = 0;
*/
int
st_key_create
(
int
*
keyp
,
_st_destructor_t
destructor
)
{
if
(
key_max
>=
ST_KEYS_MAX
)
{
errno
=
EAGAIN
;
return
-
1
;
}
*
keyp
=
key_max
++
;
_st_destructors
[
*
keyp
]
=
destructor
;
return
0
;
if
(
key_max
>=
ST_KEYS_MAX
)
{
errno
=
EAGAIN
;
return
-
1
;
}
*
keyp
=
key_max
++
;
_st_destructors
[
*
keyp
]
=
destructor
;
return
0
;
}
int
st_key_getlimit
(
void
)
{
return
ST_KEYS_MAX
;
return
ST_KEYS_MAX
;
}
int
st_thread_setspecific
(
int
key
,
void
*
value
)
{
_st_thread_t
*
me
=
_ST_CURRENT_THREAD
();
if
(
key
<
0
||
key
>=
key_max
)
{
errno
=
EINVAL
;
return
-
1
;
}
if
(
value
!=
me
->
private_data
[
key
])
{
/* free up previously set non-NULL data value */
if
(
me
->
private_data
[
key
]
&&
_st_destructors
[
key
])
{
(
*
_st_destructors
[
key
])(
me
->
private_data
[
key
]);
_st_thread_t
*
me
=
_ST_CURRENT_THREAD
();
if
(
key
<
0
||
key
>=
key_max
)
{
errno
=
EINVAL
;
return
-
1
;
}
me
->
private_data
[
key
]
=
value
;
}
return
0
;
if
(
value
!=
me
->
private_data
[
key
])
{
/* free up previously set non-NULL data value */
if
(
me
->
private_data
[
key
]
&&
_st_destructors
[
key
])
{
(
*
_st_destructors
[
key
])(
me
->
private_data
[
key
]);
}
me
->
private_data
[
key
]
=
value
;
}
return
0
;
}
void
*
st_thread_getspecific
(
int
key
)
{
if
(
key
<
0
||
key
>=
key_max
)
return
NULL
;
return
((
_ST_CURRENT_THREAD
())
->
private_data
[
key
]);
if
(
key
<
0
||
key
>=
key_max
)
{
return
NULL
;
}
return
((
_ST_CURRENT_THREAD
())
->
private_data
[
key
]);
}
...
...
@@ -109,13 +110,13 @@ void *st_thread_getspecific(int key)
*/
void
_st_thread_cleanup
(
_st_thread_t
*
thread
)
{
int
key
;
for
(
key
=
0
;
key
<
key_max
;
key
++
)
{
if
(
thread
->
private_data
[
key
]
&&
_st_destructors
[
key
])
{
(
*
_st_destructors
[
key
])(
thread
->
private_data
[
key
]);
thread
->
private_data
[
key
]
=
NULL
;
int
key
;
for
(
key
=
0
;
key
<
key_max
;
key
++
)
{
if
(
thread
->
private_data
[
key
]
&&
_st_destructors
[
key
])
{
(
*
_st_destructors
[
key
])(
thread
->
private_data
[
key
]);
thread
->
private_data
[
key
]
=
NULL
;
}
}
}
}
...
...
请
注册
或
登录
后发表评论