Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c776680c
提交
c776680c
authored
4月 15, 2019
作者:
Chris Rienzo
提交者:
Andrey Volk
7月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11785 [core, mod_commands] update XML API to fix scan-build false positive memory leaks
上级
3f46ce1d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
42 行增加
和
10 行删除
+42
-10
switch_xml.h
src/include/switch_xml.h
+9
-8
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+2
-2
switch_xml.c
src/switch_xml.c
+31
-0
没有找到文件。
src/include/switch_xml.h
浏览文件 @
c776680c
...
...
@@ -266,8 +266,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(_In_ switch_xml_t xml, _In_z_
///\param xml the xml node
///\param name the name of the child
///\param off the offset
#define switch_xml_add_child_d(xml, name, off) \
switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_add_child_d
(
_In_
switch_xml_t
xml
,
_In_z_
const
char
*
name
,
_In_
switch_size_t
off
);
///\brief sets the character content for the given tag and returns the tag
///\param xml the xml node
...
...
@@ -280,8 +279,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *tx
///\param xml the xml node
///\param txt the text
///\return an xml node or NULL
#define switch_xml_set_txt_d(xml, txt) \
switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_txt_d
(
switch_xml_t
xml
,
const
char
*
txt
);
///\brief Sets the given tag attribute or adds a new attribute if not found. A value
///\ of NULL will remove the specified attribute.
...
...
@@ -296,11 +294,14 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr(switch_xml_t xml, const char *n
///\param name the attribute name
///\param value the attribute value
///\return an xml node or NULL
#define switch_xml_set_attr_d(xml, name, value) \
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)))
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_attr_d
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
);
#define switch_xml_set_attr_d_buf(xml, name, value) \
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
///\brief Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
///\param xml the xml node
///\param name the attribute name
///\param value the attribute value
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_attr_d_buf
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
);
///\brief sets a flag for the given tag and returns the tag
///\param xml the xml node
...
...
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
c776680c
...
...
@@ -5473,7 +5473,7 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column
switch_snprintf
(
id
,
sizeof
(
id
),
"%d"
,
holder
->
rows
);
switch_xml_set_attr
(
switch_xml_set_flag
(
row
,
SWITCH_XML_DUP
),
strdup
(
"row_id"
),
strdup
(
id
)
);
switch_xml_set_attr
_d_buf
(
row
,
"row_id"
,
id
);
for
(
x
=
0
;
x
<
argc
;
x
++
)
{
char
*
name
=
columnNames
[
x
];
...
...
@@ -5864,7 +5864,7 @@ SWITCH_STANDARD_API(show_function)
char
*
xmlstr
;
switch_snprintf
(
count
,
sizeof
(
count
),
"%d"
,
holder
.
count
);
switch_xml_set_attr
(
switch_xml_set_flag
(
holder
.
xml
,
SWITCH_XML_DUP
),
strdup
(
"row_count"
),
strdup
(
count
)
);
switch_xml_set_attr
(
holder
.
xml
,
"row_count"
,
count
);
xmlstr
=
switch_xml_toxml
(
holder
.
xml
,
SWITCH_FALSE
);
switch_xml_free
(
holder
.
xml
);
...
...
src/switch_xml.c
浏览文件 @
c776680c
...
...
@@ -2942,6 +2942,14 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *
return
switch_xml_insert
(
child
,
xml
,
off
);
}
/* Adds a child tag. off is the offset of the child tag relative to the start
of the parent tag's character content. Returns the child tag */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_add_child_d
(
switch_xml_t
xml
,
const
char
*
name
,
switch_size_t
off
)
{
if
(
!
xml
)
return
NULL
;
return
switch_xml_set_flag
(
switch_xml_add_child
(
xml
,
strdup
(
name
),
off
),
SWITCH_XML_NAMEM
);
}
/* sets the character content for the given tag and returns the tag */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_txt
(
switch_xml_t
xml
,
const
char
*
txt
)
{
...
...
@@ -2954,6 +2962,13 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *tx
return
xml
;
}
/* sets the character content for the given tag and returns the tag */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_txt_d
(
switch_xml_t
xml
,
const
char
*
txt
)
{
if
(
!
xml
)
return
NULL
;
return
switch_xml_set_flag
(
switch_xml_set_txt
(
xml
,
strdup
(
txt
)),
SWITCH_XML_TXTM
);
}
/* Sets the given tag attribute or adds a new attribute if not found. A value
of NULL will remove the specified attribute. Returns the tag given */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_attr
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
)
...
...
@@ -3005,6 +3020,22 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr(switch_xml_t xml, const char *n
return
xml
;
}
/* Sets the given tag attribute or adds a new attribute if not found. A value
of NULL will remove the specified attribute. Returns the tag given */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_attr_d
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
)
{
if
(
!
xml
)
return
NULL
;
return
switch_xml_set_attr
(
switch_xml_set_flag
(
xml
,
SWITCH_XML_DUP
),
strdup
(
name
),
strdup
(
switch_str_nil
(
value
)));
}
/* Sets the given tag attribute or adds a new attribute if not found. A value
of NULL will remove the specified attribute. Returns the tag given */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_attr_d_buf
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
)
{
if
(
!
xml
)
return
NULL
;
return
switch_xml_set_attr
(
switch_xml_set_flag
(
xml
,
SWITCH_XML_DUP
),
strdup
(
name
),
strdup
(
value
));
}
/* sets a flag for the given tag and returns the tag */
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_flag
(
switch_xml_t
xml
,
switch_xml_flag_t
flag
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论