aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-01-29 23:49:59 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:46 +0100
commite3f328e4a24e2161fba58585e9f607c429b24c1b (patch)
tree2582ca2bdf221e3439bcabe688972f5cb1d5b4fe /src/base
parent2f2d371dbda69a3a364cd875c8181b072bcd7aeb (diff)
downloadusdx-e3f328e4a24e2161fba58585e9f607c429b24c1b.tar.gz
usdx-e3f328e4a24e2161fba58585e9f607c429b24c1b.tar.xz
usdx-e3f328e4a24e2161fba58585e9f607c429b24c1b.zip
delete all members of containers with std::for_each
Diffstat (limited to 'src/base')
-rw-r--r--src/base/language.cpp14
-rw-r--r--src/base/songloading/songloader.cpp15
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