Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
7e6b59ff
提交
7e6b59ff
authored
6月 09, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some various api util
上级
7d2e2ce0
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
95 行增加
和
2 行删除
+95
-2
switch_apr.h
src/include/switch_apr.h
+2
-0
switch_buffer.h
src/include/switch_buffer.h
+2
-0
switch_core.h
src/include/switch_core.h
+28
-2
switch_buffer.c
src/switch_buffer.c
+16
-0
switch_core_hash.c
src/switch_core_hash.c
+47
-0
没有找到文件。
src/include/switch_apr.h
浏览文件 @
7e6b59ff
...
@@ -1202,6 +1202,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const
...
@@ -1202,6 +1202,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const
*/
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_sendto
(
switch_socket_t
*
sock
,
switch_sockaddr_t
*
where
,
int32_t
flags
,
const
char
*
buf
,
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_sendto
(
switch_socket_t
*
sock
,
switch_sockaddr_t
*
where
,
int32_t
flags
,
const
char
*
buf
,
switch_size_t
*
len
);
switch_size_t
*
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_send_nonblock
(
switch_socket_t
*
sock
,
const
char
*
buf
,
switch_size_t
*
len
);
/**
/**
* @param from The apr_sockaddr_t to fill in the recipient info
* @param from The apr_sockaddr_t to fill in the recipient info
...
...
src/include/switch_buffer.h
浏览文件 @
7e6b59ff
...
@@ -109,6 +109,8 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_read(_In_ switch_buffer_t *buffer, _
...
@@ -109,6 +109,8 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_read(_In_ switch_buffer_t *buffer, _
*/
*/
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_peek
(
_In_
switch_buffer_t
*
buffer
,
_In_
void
*
data
,
_In_
switch_size_t
datalen
);
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_peek
(
_In_
switch_buffer_t
*
buffer
,
_In_
void
*
data
,
_In_
switch_size_t
datalen
);
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_peek_zerocopy
(
_In_
switch_buffer_t
*
buffer
,
_Out_
const
void
**
ptr
);
/*! \brief Read data endlessly from a switch_buffer_t
/*! \brief Read data endlessly from a switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \param data pointer to the read data to be returned
* \param data pointer to the read data to be returned
...
...
src/include/switch_core.h
浏览文件 @
7e6b59ff
...
@@ -1227,7 +1227,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t *hash
...
@@ -1227,7 +1227,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t *hash
\note the string key must be a constant or a dynamic string
\note the string key must be a constant or a dynamic string
*/
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_insert_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_opt_
const
void
*
data
,
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_insert_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_opt_
const
void
*
data
,
_In_
switch_mutex_t
*
mutex
);
_In_opt_
switch_mutex_t
*
mutex
);
/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
\param mutex optional rwlock to wrlock
\return a pointer to the data held in the key
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_insert_wrlock
(
switch_hash_t
*
hash
,
const
char
*
key
,
const
void
*
data
,
switch_thread_rwlock_t
*
rwlock
);
/*!
/*!
\brief Delete data from a hash based on desired key
\brief Delete data from a hash based on desired key
...
@@ -1244,7 +1252,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t *hash
...
@@ -1244,7 +1252,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t *hash
\param mutex optional mutex to lock
\param mutex optional mutex to lock
\return SWITCH_STATUS_SUCCESS if the data is deleted
\return SWITCH_STATUS_SUCCESS if the data is deleted
*/
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_
switch_mutex_t
*
mutex
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_opt_
switch_mutex_t
*
mutex
);
/*!
\brief Delete data from a hash based on desired key
\param hash the hash to delete from
\param key the key from which to delete the data
\param mutex optional rwlock to wrlock
\return SWITCH_STATUS_SUCCESS if the data is deleted
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_wrlock
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_opt_
switch_thread_rwlock_t
*
rwlock
);
/*!
/*!
\brief Delete data from a hash based on callback function
\brief Delete data from a hash based on callback function
...
@@ -1272,6 +1289,15 @@ SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ co
...
@@ -1272,6 +1289,15 @@ SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ co
*/
*/
SWITCH_DECLARE
(
void
*
)
switch_core_hash_find_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_
switch_mutex_t
*
mutex
);
SWITCH_DECLARE
(
void
*
)
switch_core_hash_find_locked
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_
switch_mutex_t
*
mutex
);
/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
\param mutex optional rwlock to rdlock
\return a pointer to the data held in the key
*/
SWITCH_DECLARE
(
void
*
)
switch_core_hash_find_rdlock
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_
switch_thread_rwlock_t
*
rwlock
);
/*!
/*!
\brief Gets the first element of a hashtable
\brief Gets the first element of a hashtable
\param depricate_me [deprecated] NULL
\param depricate_me [deprecated] NULL
...
...
src/switch_buffer.c
浏览文件 @
7e6b59ff
...
@@ -224,6 +224,22 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_peek(switch_buffer_t *buffer, void *
...
@@ -224,6 +224,22 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_peek(switch_buffer_t *buffer, void *
return
reading
;
return
reading
;
}
}
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_peek_zerocopy
(
switch_buffer_t
*
buffer
,
const
void
**
ptr
)
{
switch_size_t
reading
=
0
;
if
(
buffer
->
used
<
1
)
{
buffer
->
used
=
0
;
return
0
;
}
else
{
reading
=
buffer
->
used
;
}
*
ptr
=
buffer
->
head
;
return
reading
;
}
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_write
(
switch_buffer_t
*
buffer
,
const
void
*
data
,
switch_size_t
datalen
)
SWITCH_DECLARE
(
switch_size_t
)
switch_buffer_write
(
switch_buffer_t
*
buffer
,
const
void
*
data
,
switch_size_t
datalen
)
{
{
switch_size_t
freespace
,
actual_freespace
;
switch_size_t
freespace
,
actual_freespace
;
...
...
src/switch_core_hash.c
浏览文件 @
7e6b59ff
...
@@ -96,6 +96,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t *ha
...
@@ -96,6 +96,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t *ha
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_insert_wrlock
(
switch_hash_t
*
hash
,
const
char
*
key
,
const
void
*
data
,
switch_thread_rwlock_t
*
rwlock
)
{
if
(
rwlock
)
{
switch_thread_rwlock_wrlock
(
rwlock
);
}
sqlite3HashInsert
(
&
hash
->
table
,
key
,
(
int
)
strlen
(
key
)
+
1
,
(
void
*
)
data
);
if
(
rwlock
)
{
switch_thread_rwlock_unlock
(
rwlock
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete
(
switch_hash_t
*
hash
,
const
char
*
key
)
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete
(
switch_hash_t
*
hash
,
const
char
*
key
)
{
{
sqlite3HashInsert
(
&
hash
->
table
,
key
,
(
int
)
strlen
(
key
)
+
1
,
NULL
);
sqlite3HashInsert
(
&
hash
->
table
,
key
,
(
int
)
strlen
(
key
)
+
1
,
NULL
);
...
@@ -117,6 +132,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t *ha
...
@@ -117,6 +132,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t *ha
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_wrlock
(
switch_hash_t
*
hash
,
const
char
*
key
,
switch_thread_rwlock_t
*
rwlock
)
{
if
(
rwlock
)
{
switch_thread_rwlock_wrlock
(
rwlock
);
}
sqlite3HashInsert
(
&
hash
->
table
,
key
,
(
int
)
strlen
(
key
)
+
1
,
NULL
);
if
(
rwlock
)
{
switch_thread_rwlock_unlock
(
rwlock
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi
(
switch_hash_t
*
hash
,
switch_hash_delete_callback_t
callback
,
void
*
pData
)
{
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi
(
switch_hash_t
*
hash
,
switch_hash_delete_callback_t
callback
,
void
*
pData
)
{
switch_hash_index_t
*
hi
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
...
@@ -175,6 +205,23 @@ SWITCH_DECLARE(void *) switch_core_hash_find_locked(switch_hash_t *hash, const c
...
@@ -175,6 +205,23 @@ SWITCH_DECLARE(void *) switch_core_hash_find_locked(switch_hash_t *hash, const c
return
val
;
return
val
;
}
}
SWITCH_DECLARE
(
void
*
)
switch_core_hash_find_rdlock
(
switch_hash_t
*
hash
,
const
char
*
key
,
switch_thread_rwlock_t
*
rwlock
)
{
void
*
val
;
if
(
rwlock
)
{
switch_thread_rwlock_rdlock
(
rwlock
);
}
val
=
sqlite3HashFind
(
&
hash
->
table
,
key
,
(
int
)
strlen
(
key
)
+
1
);
if
(
rwlock
)
{
switch_thread_rwlock_unlock
(
rwlock
);
}
return
val
;
}
SWITCH_DECLARE
(
switch_hash_index_t
*
)
switch_hash_first
(
char
*
depricate_me
,
switch_hash_t
*
hash
)
SWITCH_DECLARE
(
switch_hash_index_t
*
)
switch_hash_first
(
char
*
depricate_me
,
switch_hash_t
*
hash
)
{
{
return
(
switch_hash_index_t
*
)
sqliteHashFirst
(
&
hash
->
table
);
return
(
switch_hash_index_t
*
)
sqliteHashFirst
(
&
hash
->
table
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论