Commit 98e53134 authored by Jacob Gladish's avatar Jacob Gladish

Fixed some memory leaks based on valgrind.

Removed some dead code from Guid.
parent cde4b01b
#include "BridgeConfig.h" #include "BridgeConfig.h"
#include "Common/Log.h" #include "Common/Log.h"
#include <memory>
#include <mutex>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
...@@ -145,6 +147,23 @@ namespace ...@@ -145,6 +147,23 @@ namespace
DSBLOG_INFO("%s == %s", xpath, content.c_str()); DSBLOG_INFO("%s == %s", xpath, content.c_str());
return content; return content;
} }
class LibXmlInitializer
{
public:
LibXmlInitializer()
{
xmlInitParser();
}
~LibXmlInitializer()
{
xmlCleanupParser();
}
};
std::once_flag libXmlInit;
std::shared_ptr<LibXmlInitializer> libXmlInitializer;
} }
bridge::BridgeConfig::BridgeConfig() bridge::BridgeConfig::BridgeConfig()
...@@ -166,7 +185,10 @@ bridge::BridgeConfig::FromFile(std::string const& fileName) ...@@ -166,7 +185,10 @@ bridge::BridgeConfig::FromFile(std::string const& fileName)
m_fileName = fileName; m_fileName = fileName;
installXmlLogger(); installXmlLogger();
xmlInitParser();
std::call_once(libXmlInit, [] {
if (!libXmlInitializer) libXmlInitializer.reset(new LibXmlInitializer());
});
xmlDocPtr doc = xmlParseFile(m_fileName.c_str()); xmlDocPtr doc = xmlParseFile(m_fileName.c_str());
if (!doc) if (!doc)
......
...@@ -14,13 +14,6 @@ common::Guid::Guid(uuid_t id) ...@@ -14,13 +14,6 @@ common::Guid::Guid(uuid_t id)
common::Guid common::Guid
common::Guid::NewGuid() common::Guid::NewGuid()
{ {
#ifdef __linux__
char id[17];
memset(id, 0, sizeof(id));
#else
uuid_string_t id;
#endif
uuid_t uuid; uuid_t uuid;
uuid_generate_random(uuid); uuid_generate_random(uuid);
return Guid(uuid); return Guid(uuid);
...@@ -33,10 +26,9 @@ common::Guid::Parse(char const* s) ...@@ -33,10 +26,9 @@ common::Guid::Parse(char const* s)
return Guid::Null(); return Guid::Null();
uuid_t id; uuid_t id;
if (uuid_parse(s, id) == 0) return (uuid_parse(s, id) == 0)
return Guid(id); ? Guid(id)
else : Guid::Null();
return Guid::Null();
} }
common::Guid const& common::Guid const&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment