summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorayuanx <ayuanx@gmail.com>2009-11-24 17:10:38 +0000
committerayuanx <ayuanx@gmail.com>2009-11-24 17:10:38 +0000
commit29774c35e8a4077cad3a2db01e657ada96fc906b (patch)
tree993c051dbd3783a99395a4359a788d0dd50b83e6 /Source/Core/Common
parent6a46befc2aa419a9c0527f52cdced3fd3adfae0e (diff)
My first commit :)
Fixed more memory leaks when doing state load. Now all file devices(handles) are stored in state, and this will fix some crash after loading state. Warning: Do NOT Save/Load state before game title is shown and controllable, or else you will get a corrupt state. If you encounter "Emu WiiMote Desync" frequently, please report the condition (PS: To recover from wiimote desync, just load a saved state) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4608 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/ChunkFile.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h
index 706b0d7be9..00b50b4a8d 100644
--- a/Source/Core/Common/Src/ChunkFile.h
+++ b/Source/Core/Common/Src/ChunkFile.h
@@ -74,13 +74,48 @@ public:
(*ptr) += size;
}
- // Store maps to file. Very useful.
template<class T>
- void Do(std::map<unsigned int, T> &x) {
+ void Do(std::map<unsigned int, T> &x)
+ {
// TODO
PanicAlert("Do(map<>) does not yet work.");
}
-
+
+ void Do(std::map<unsigned int, std::string> &x)
+ {
+ unsigned int number = (unsigned int)x.size();
+ Do(number);
+ switch (mode) {
+ case MODE_READ:
+ {
+ x.clear();
+ while (number > 0)
+ {
+ unsigned int first;
+ Do(first);
+ std::string second;
+ Do(second);
+ x[first] = second;
+ --number;
+ }
+ }
+ break;
+ case MODE_WRITE:
+ case MODE_MEASURE:
+ {
+ std::map<unsigned int, std::string>::iterator itr = x.begin();
+ while (number > 0)
+ {
+ Do(itr->first);
+ Do(itr->second);
+ --number;
+ ++itr;
+ }
+ }
+ break;
+ }
+ }
+
// Store vectors.
template<class T>
void Do(std::vector<T> &x) {