Hey,
the URL copying in xml_recreate_namespace() is unnecessary as all URLs are
constant.
Kaspar
Signed-off-by: Kaspar Schleiser <kaspar@schleiser.de>
---
src/xml/xml.c | 56 +++++++++++---------------------------------------------
src/xml/xml.h | 5 -----
2 files changed, 11 insertions(+), 50 deletions(-)
diff --git a/src/xml/xml.c b/src/xml/xml.c
index 3e9198f..2e4c07b 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -17,6 +17,12 @@
#include "xml.h"
+const static char *soap_env_url = "http://schemas.xmlsoap.org/soap/envelope/";
+const static char *soap_enc_url = "http://schemas.xmlsoap.org/soap/encoding/";
+const static char *xsd_url = "http://www.w3.org/2001/XMLSchema";
+const static char *xsi_url = "http://www.w3.org/2001/XMLSchema-instance";
+const static char *cwmp_url = "urn:dslforum-org:cwmp-1-2";
+
static void
xml_recreate_namespace(char *msg)
{
@@ -40,27 +46,27 @@ xml_recreate_namespace(char *msg)
if (!tree)
goto done;
- c = (char *) mxmlElementGetAttrName(tree, ns.soap_env_url);
+ c = (char *) mxmlElementGetAttrName(tree, soap_env_url);
if (*(c + 5) == ':') {
ns.soap_env = strdup((c + 6));
}
- c = (char *) mxmlElementGetAttrName(tree, ns.soap_enc_url);
+ c = (char *) mxmlElementGetAttrName(tree, soap_enc_url);
if (*(c + 5) == ':') {
ns.soap_enc = strdup((c + 6));
}
- c = (char *) mxmlElementGetAttrName(tree, ns.xsd_url);
+ c = (char *) mxmlElementGetAttrName(tree, xsd_url);
if (*(c + 5) == ':') {
ns.xsd = strdup((c + 6));
}
- c = (char *) mxmlElementGetAttrName(tree, ns.xsi_url);
+ c = (char *) mxmlElementGetAttrName(tree, xsi_url);
if (*(c + 5) == ':') {
ns.xsi = strdup((c + 6));
}
- c = (char *) mxmlElementGetAttrName(tree, ns.cwmp_url);
+ c = (char *) mxmlElementGetAttrName(tree, cwmp_url);
if (*(c + 5) == ':') {
ns.cwmp = strdup((c + 6));
}
@@ -74,24 +80,8 @@ int8_t
xml_init(void)
{
FC_DEVEL_DEBUG("enter");
- char *c;
int8_t status;
-
- c = "http://schemas.xmlsoap.org/soap/envelope/";
- ns.soap_env_url = strdup(c);
-
- c = "http://schemas.xmlsoap.org/soap/encoding/";
- ns.soap_enc_url = strdup(c);
- c = "http://www.w3.org/2001/XMLSchema";
- ns.xsd_url = strdup(c);
-
- c = "http://www.w3.org/2001/XMLSchema-instance";
- ns.xsi_url = strdup(c);
-
- c = "urn:dslforum-org:cwmp-1-2";
- ns.cwmp_url = strdup(c);
-
status = FC_SUCCESS;
goto done;
@@ -113,46 +103,22 @@ xml_exit(void)
{
FC_DEVEL_DEBUG("enter");
- if (ns.soap_env_url) {
- free(ns.soap_env_url);
- ns.soap_env_url = NULL;
- }
if (ns.soap_env) {
free(ns.soap_env);
ns.soap_env = NULL;
}
- if (ns.soap_enc_url) {
- free(ns.soap_enc_url);
- ns.soap_enc_url = NULL;
- }
if (ns.soap_enc) {
free(ns.soap_enc);
ns.soap_enc = NULL;
}
- if (ns.xsd_url) {
- free(ns.xsd_url);
- ns.xsd_url = NULL;
- }
if (ns.xsd) {
free(ns.xsd);
ns.xsd = NULL;
}
- if (ns.xsi_url) {
- free(ns.xsi_url);
- ns.xsi_url = NULL;
- }
if (ns.xsi) {
free(ns.xsi);
ns.xsi = NULL;
}
- if (ns.cwmp_url) {
- free(ns.cwmp_url);
- ns.cwmp_url = NULL;
- }
- if (ns.cwmp) {
- free(ns.cwmp);
- ns.cwmp = NULL;
- }
FC_DEVEL_DEBUG("exit");
return FC_SUCCESS;
diff --git a/src/xml/xml.h b/src/xml/xml.h
index 184ac8c..ec99e25 100644
--- a/src/xml/xml.h
+++ b/src/xml/xml.h
@@ -12,15 +12,10 @@
static struct cwmp_namespaces
{
- char *soap_env_url;
char *soap_env;
- char *soap_enc_url;
char *soap_enc;
- char *xsd_url;
char *xsd;
- char *xsi_url;
char *xsi;
- char *cwmp_url;
char *cwmp;
} ns;
--
1.7.9
|