diff options
Diffstat (limited to '')
-rw-r--r-- | src/base/language.cpp | 14 | ||||
-rw-r--r-- | src/base/songloading/songloader.cpp | 15 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/base/language.cpp b/src/base/language.cpp index 340cdac4..74766795 100644 --- a/src/base/language.cpp +++ b/src/base/language.cpp @@ -50,8 +50,22 @@ namespace usdx { } + void remove_element(std::pair<std::wstring, std::map<std::wstring, std::wstring>*> element) + { + if (element.second) { + element.second->clear(); + } + + delete element.second; + element.second = NULL; + } + Language::~Language(void) { + // clear memory for all elements in the map + std::for_each(translations.begin(), translations.end(), + remove_element); + translations.clear(); // remove reference from singleton to make regeneration possible instance = NULL; diff --git a/src/base/songloading/songloader.cpp b/src/base/songloading/songloader.cpp index b86f3100..9c1401ec 100644 --- a/src/base/songloading/songloader.cpp +++ b/src/base/songloading/songloader.cpp @@ -42,14 +42,17 @@ namespace usdx strategies[".xml"] = new SongloadingStrategyXml(); } - Songloader::~Songloader(void) + void remove_element(std::pair<std::string, SongloadingStrategy*> e) { - std::map<std::string, SongloadingStrategy*>::iterator it; - for (it = strategies.begin(); it != strategies.end(); it++) { - delete it->second; - it->second = NULL; - } + delete e.second; + e.second = NULL; + } + Songloader::~Songloader(void) + { + // clear memory for all elements in the map + std::for_each(strategies.begin(), strategies.end(), + remove_element); strategies.clear(); // remove reference from singleton to make regeneration possible |