summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-06-24 13:39:27 -0400
committerLioncash <mathew1800@gmail.com>2014-06-24 13:39:27 -0400
commit832d0bbdb94472917b111c06b7e54a47f4be4fcf (patch)
tree65def7ad054da31588d22835b40f05751887e65e /Source/Core
parent4138702336601b79938889a68144c24c03ccfc14 (diff)
parent516369594f475f93df290d6488c2eccd99618023 (diff)
Merge pull request #534 from jordan-woyak/ini-file-fix
Store ini sections in a std::list to prevent pointer invalidation.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/IniFile.cpp4
-rw-r--r--Source/Core/Common/IniFile.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp
index 6159c2897d..da9d99e250 100644
--- a/Source/Core/Common/IniFile.cpp
+++ b/Source/Core/Common/IniFile.cpp
@@ -233,7 +233,7 @@ IniFile::Section* IniFile::GetOrCreateSection(const std::string& sectionName)
if (!section)
{
sections.push_back(Section(sectionName));
- section = &sections[sections.size() - 1];
+ section = &sections.back();
}
return section;
}
@@ -323,7 +323,7 @@ bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>*
void IniFile::SortSections()
{
- std::sort(sections.begin(), sections.end());
+ sections.sort();
}
bool IniFile::Load(const std::string& filename, bool keep_current_data)
diff --git a/Source/Core/Common/IniFile.h b/Source/Core/Common/IniFile.h
index 1d006b802f..3ff7e39794 100644
--- a/Source/Core/Common/IniFile.h
+++ b/Source/Core/Common/IniFile.h
@@ -5,6 +5,7 @@
#pragma once
#include <cstring>
+#include <list>
#include <map>
#include <string>
#include <vector>
@@ -116,7 +117,7 @@ public:
Section* GetOrCreateSection(const std::string& section);
private:
- std::vector<Section> sections;
+ std::list<Section> sections;
const Section* GetSection(const std::string& section) const;
Section* GetSection(const std::string& section);