Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
78bbe8f5
提交
78bbe8f5
authored
1月 21, 2019
作者:
Mariah Yang
提交者:
Andrey Volk
7月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11621: add switch_core_strndup
上级
7aac844f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
3 行删除
+9
-3
switch_core.h
src/include/switch_core.h
+4
-0
switch_core_memory.c
src/switch_core_memory.c
+5
-3
没有找到文件。
src/include/switch_core.h
浏览文件 @
78bbe8f5
...
@@ -724,6 +724,8 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_sessi
...
@@ -724,6 +724,8 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_sessi
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strdup
(
_In_
switch_memory_pool_t
*
pool
,
_In_z_
const
char
*
todup
,
_In_z_
const
char
*
file
,
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strdup
(
_In_
switch_memory_pool_t
*
pool
,
_In_z_
const
char
*
todup
,
_In_z_
const
char
*
file
,
_In_z_
const
char
*
func
,
_In_
int
line
);
_In_z_
const
char
*
func
,
_In_
int
line
);
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strndup
(
_In_
switch_memory_pool_t
*
pool
,
_In_z_
const
char
*
todup
,
size_t
len
,
_In_z_
const
char
*
file
,
_In_z_
const
char
*
func
,
_In_
int
line
);
/*!
/*!
\brief Copy a string using memory allocation from a given pool
\brief Copy a string using memory allocation from a given pool
...
@@ -733,6 +735,8 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *poo
...
@@ -733,6 +735,8 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *poo
*/
*/
#define switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_core_strndup(_pool, _todup, _len) switch_core_perform_strndup(_pool, _todup, _len, __FILE__, __SWITCH_FUNC__, __LINE__)
/*!
/*!
\brief printf-style style printing routine. The data is output to a string allocated from the session
\brief printf-style style printing routine. The data is output to a string allocated from the session
\param session a session to use for allocation
\param session a session to use for allocation
...
...
src/switch_core_memory.c
浏览文件 @
78bbe8f5
...
@@ -269,9 +269,13 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
...
@@ -269,9 +269,13 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
}
}
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strdup
(
switch_memory_pool_t
*
pool
,
const
char
*
todup
,
const
char
*
file
,
const
char
*
func
,
int
line
)
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strdup
(
switch_memory_pool_t
*
pool
,
const
char
*
todup
,
const
char
*
file
,
const
char
*
func
,
int
line
)
{
return
switch_core_perform_strndup
(
pool
,
todup
,
todup
?
strlen
(
todup
)
+
1
:
0
,
file
,
func
,
line
);
}
SWITCH_DECLARE
(
char
*
)
switch_core_perform_strndup
(
switch_memory_pool_t
*
pool
,
const
char
*
todup
,
size_t
len
,
const
char
*
file
,
const
char
*
func
,
int
line
)
{
{
char
*
duped
=
NULL
;
char
*
duped
=
NULL
;
switch_size_t
len
;
switch_assert
(
pool
!=
NULL
);
switch_assert
(
pool
!=
NULL
);
if
(
!
todup
)
{
if
(
!
todup
)
{
...
@@ -287,8 +291,6 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
...
@@ -287,8 +291,6 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
#endif
#endif
#endif
#endif
len
=
strlen
(
todup
)
+
1
;
#ifdef DEBUG_ALLOC
#ifdef DEBUG_ALLOC
if
(
len
>
DEBUG_ALLOC_CUTOFF
)
if
(
len
>
DEBUG_ALLOC_CUTOFF
)
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
NULL
,
SWITCH_LOG_CONSOLE
,
"%p Core Strdup Allocate %s %d
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
NULL
,
SWITCH_LOG_CONSOLE
,
"%p Core Strdup Allocate %s %d
\n
"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论