Fix memory leaks on the collections/variables management

This commit is contained in:
Felipe Zimmerle 2016-02-16 18:56:26 -03:00
parent 49fc1f8b79
commit e346454374
4 changed files with 12 additions and 5 deletions

View File

@ -40,6 +40,7 @@ class Variables :
public std::unordered_multimap<std::string, std::string> { public std::unordered_multimap<std::string, std::string> {
public: public:
Variables(); Variables();
~Variables();
void store(std::string key, std::string value); void store(std::string key, std::string value);
bool storeOrUpdateFirst(const std::string &key, bool storeOrUpdateFirst(const std::string &key,

View File

@ -37,7 +37,12 @@ Collections::Collections() {
} }
Collections::~Collections() { } Collections::~Collections() {
for (auto &a : *this) {
this->erase(a.first);
delete a.second;
}
}
void Collections::init(const std::string& name, const std::string& key) { void Collections::init(const std::string& name, const std::string& key) {

View File

@ -148,10 +148,6 @@ Transaction::~Transaction() {
m_requestBody.str(std::string()); m_requestBody.str(std::string());
m_requestBody.clear(); m_requestBody.clear();
for (auto &a : m_collections) {
delete a.second;
}
m_rules->decrementReferenceCount(); m_rules->decrementReferenceCount();
} }

View File

@ -34,6 +34,11 @@ Variables::Variables() {
this->reserve(1000); this->reserve(1000);
} }
Variables::~Variables() {
for (auto &a : *this) {
this->erase(a.first);
}
}
void Variables::store(std::string key, std::string value) { void Variables::store(std::string key, std::string value) {
this->emplace(key, value); this->emplace(key, value);