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 "Common/Log.h"
#include <memory>
#include <mutex>
#include <string>
#include <sstream>
#include <string.h>
......@@ -145,6 +147,23 @@ namespace
DSBLOG_INFO("%s == %s", xpath, content.c_str());
return content;
}
class LibXmlInitializer
{
public:
LibXmlInitializer()
{
xmlInitParser();
}
~LibXmlInitializer()
{
xmlCleanupParser();
}
};
std::once_flag libXmlInit;
std::shared_ptr<LibXmlInitializer> libXmlInitializer;
}
bridge::BridgeConfig::BridgeConfig()
......@@ -166,7 +185,10 @@ bridge::BridgeConfig::FromFile(std::string const& fileName)
m_fileName = fileName;
installXmlLogger();
xmlInitParser();
std::call_once(libXmlInit, [] {
if (!libXmlInitializer) libXmlInitializer.reset(new LibXmlInitializer());
});
xmlDocPtr doc = xmlParseFile(m_fileName.c_str());
if (!doc)
......
......@@ -14,13 +14,6 @@ common::Guid::Guid(uuid_t id)
common::Guid
common::Guid::NewGuid()
{
#ifdef __linux__
char id[17];
memset(id, 0, sizeof(id));
#else
uuid_string_t id;
#endif
uuid_t uuid;
uuid_generate_random(uuid);
return Guid(uuid);
......@@ -33,10 +26,9 @@ common::Guid::Parse(char const* s)
return Guid::Null();
uuid_t id;
if (uuid_parse(s, id) == 0)
return Guid(id);
else
return Guid::Null();
return (uuid_parse(s, id) == 0)
? Guid(id)
: Guid::Null();
}
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