summaryrefslogtreecommitdiff
path: root/src/configuration.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-22 19:07:38 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-22 19:07:38 +0000
commitd69c8e1bccaf383a73bf2c122794cfc467f4b6e7 (patch)
treeee362d7dd9b7d112014617ec44a4fce3b92ae6ce /src/configuration.cpp
parent777bc93bbfb2eae527533c824ff0fa453f8cc82b (diff)
downloadMana-d69c8e1bccaf383a73bf2c122794cfc467f4b6e7.tar.gz
Mana-d69c8e1bccaf383a73bf2c122794cfc467f4b6e7.tar.bz2
Mana-d69c8e1bccaf383a73bf2c122794cfc467f4b6e7.tar.xz
Mana-d69c8e1bccaf383a73bf2c122794cfc467f4b6e7.zip
Plugged memory leak. Cleaned code.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r--src/configuration.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index d33df386..864ad7c3 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -53,6 +53,7 @@ void Configuration::init(const std::string &filename)
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) {
logger->log("Warning: No configuration file (%s)", filename.c_str());
+ xmlFreeDoc(doc);
return;
}
@@ -61,15 +62,13 @@ void Configuration::init(const std::string &filename)
if (!xmlStrEqual(node->name, BAD_CAST "option"))
continue;
- xmlChar *name = xmlGetProp(node, BAD_CAST "name");
- xmlChar *value = xmlGetProp(node, BAD_CAST "value");
+ std::string name = XML::getProperty(node, "name", std::string());
+ std::string value = XML::getProperty(node, "value", std::string());
- if (name && value) {
- mOptions[(const char*)name] = (const char*)value;
+ if (!name.empty() && !value.empty())
+ {
+ mOptions[name] = value;
}
-
- if (name) xmlFree(name);
- if (value) xmlFree(value);
}
xmlFreeDoc(doc);