Archived
14
0
Fork 0

Avoid a not needed cast, making code more readable.

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@157073 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
eliel 2008-11-15 15:37:11 +00:00
parent 7927af69d9
commit b17c75817d

View file

@ -584,11 +584,10 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
#define ISLAST(__rev, __a) (__rev == 1 ? (ast_xml_node_get_prev(__a) ? 0 : 1) : (ast_xml_node_get_next(__a) ? 0 : 1)) #define ISLAST(__rev, __a) (__rev == 1 ? (ast_xml_node_get_prev(__a) ? 0 : 1) : (ast_xml_node_get_next(__a) ? 0 : 1))
#define MP(__a) ((multiple ? __a : "")) #define MP(__a) ((multiple ? __a : ""))
struct ast_xml_node *node = NULL, *firstparam = NULL, *lastparam = NULL; struct ast_xml_node *node = NULL, *firstparam = NULL, *lastparam = NULL;
const char *paramtype, *multipletype, *paramname, *attrargsep, *parenthesis, *argname; const char *paramtype, *multipletype, *paramnameattr, *attrargsep, *parenthesis, *argname;
int reverse, required, paramcount = 0, openbrackets = 0, len = 0, hasparams=0; int reverse, required, paramcount = 0, openbrackets = 0, len = 0, hasparams=0;
int reqfinode = 0, reqlanode = 0, optmidnode = 0, prnparenthesis; int reqfinode = 0, reqlanode = 0, optmidnode = 0, prnparenthesis, multiple;
char *syntax = NULL, *argsep; char *syntax = NULL, *argsep, *paramname;
int paramnamemalloc, multiple;
if (ast_strlen_zero(rootname) || ast_strlen_zero(childname)) { if (ast_strlen_zero(rootname) || ast_strlen_zero(childname)) {
ast_log(LOG_WARNING, "Tried to look in XML tree with faulty rootname or childname while creating a syntax.\n"); ast_log(LOG_WARNING, "Tried to look in XML tree with faulty rootname or childname while creating a syntax.\n");
@ -696,16 +695,13 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
if (argname) { if (argname) {
paramname = xmldoc_get_syntax_fun(node, argname, "argument", prnparenthesis, prnparenthesis); paramname = xmldoc_get_syntax_fun(node, argname, "argument", prnparenthesis, prnparenthesis);
ast_xml_free_attr(argname); ast_xml_free_attr(argname);
paramnamemalloc = 1;
} else { } else {
/* Malformed XML, print **UNKOWN** */ /* Malformed XML, print **UNKOWN** */
paramname = ast_strdup("**unknown**"); paramname = ast_strdup("**unknown**");
} }
paramnamemalloc = 1;
} else { } else {
paramnamemalloc = 0; paramnameattr = ast_xml_get_attribute(node, "name");
paramname = ast_xml_get_attribute(node, "name"); if (!paramnameattr) {
if (!paramname) {
ast_log(LOG_WARNING, "Malformed XML %s: no %s name\n", rootname, childname); ast_log(LOG_WARNING, "Malformed XML %s: no %s name\n", rootname, childname);
if (syntax) { if (syntax) {
/* Free already allocated syntax */ /* Free already allocated syntax */
@ -715,6 +711,8 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")); ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : ""));
return syntax; return syntax;
} }
paramname = ast_strdup(paramnameattr);
ast_xml_free_attr(paramnameattr);
} }
/* Defaults to 'false'. */ /* Defaults to 'false'. */
@ -779,11 +777,7 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
} }
} }
} }
if (paramnamemalloc) { ast_free(paramname);
ast_free((char *) paramname);
} else {
ast_xml_free_attr(paramname);
}
paramcount++; paramcount++;
} }