提交 9fa14d52 authored 作者: Brian West's avatar Brian West

FSCORE-333

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12684 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 6d0c973e
...@@ -2022,9 +2022,14 @@ static char *switch_xml_ampencode(const char *s, switch_size_t len, char **dst, ...@@ -2022,9 +2022,14 @@ static char *switch_xml_ampencode(const char *s, switch_size_t len, char **dst,
static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max, switch_size_t start, char ***attr, uint32_t * count) static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max, switch_size_t start, char ***attr, uint32_t * count)
{ {
int i, j; int i, j;
char *txt = (char *)(xml->parent) ? xml->parent->txt : (char *)""; char *txt;
switch_size_t off = 0; switch_size_t off;
uint32_t lcount = 0; uint32_t lcount;
tailrecurse:
off = 0;
lcount = 0;
txt = (char *)(xml->parent) ? xml->parent->txt : (char *)"";
/* parent character content up to this tag */ /* parent character content up to this tag */
*s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0); *s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0);
...@@ -2101,8 +2106,12 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, ...@@ -2101,8 +2106,12 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len,
off++; /* make sure off is within bounds */ off++; /* make sure off is within bounds */
if (xml->ordered) { if (xml->ordered) {
xml = xml->ordered;
start = off;
goto tailrecurse;
/*
return switch_xml_toxml_r(xml->ordered, s, len, max, off, attr, count); return switch_xml_toxml_r(xml->ordered, s, len, max, off, attr, count);
*/
} else { } else {
if (*count > 0) if (*count > 0)
(*count)--; (*count)--;
...@@ -2197,11 +2206,13 @@ SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_ ...@@ -2197,11 +2206,13 @@ SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_
/* free the memory allocated for the switch_xml structure */ /* free the memory allocated for the switch_xml structure */
SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml) SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml)
{ {
switch_xml_root_t root = (switch_xml_root_t) xml; switch_xml_root_t root;
int i, j; int i, j;
char **a, *s; char **a, *s;
switch_xml_t orig_xml;
tailrecurse:
root = (switch_xml_root_t) xml;
if (!xml) { if (!xml) {
return; return;
} }
...@@ -2221,7 +2232,7 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml) ...@@ -2221,7 +2232,7 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml)
} }
switch_xml_free(xml->child); switch_xml_free(xml->child);
switch_xml_free(xml->ordered); /*switch_xml_free(xml->ordered);*/
if (!xml->parent) { /* free root tag allocations */ if (!xml->parent) { /* free root tag allocations */
for (i = 10; root->ent[i]; i += 2) /* 0 - 9 are default entities (<>&"') */ for (i = 10; root->ent[i]; i += 2) /* 0 - 9 are default entities (<>&"') */
...@@ -2261,6 +2272,12 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml) ...@@ -2261,6 +2272,12 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml)
free(xml->txt); /* character content */ free(xml->txt); /* character content */
if ((xml->flags & SWITCH_XML_NAMEM)) if ((xml->flags & SWITCH_XML_NAMEM))
free(xml->name); /* tag name */ free(xml->name); /* tag name */
if (xml->ordered) {
orig_xml = xml;
xml = xml->ordered;
free(orig_xml);
goto tailrecurse;
}
free(xml); free(xml);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论