mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Fixed critical bug in IniFile.
--HG-- branch : dev-2.1
This commit is contained in:
@@ -218,6 +218,8 @@ class EE_API IniFile {
|
||||
/** Delete all comments for a key. */
|
||||
bool deleteKeyComments ( unsigned const keyID );
|
||||
bool deleteKeyComments ( std::string const keyname );
|
||||
|
||||
bool iniParsed() { return mIniReaded; }
|
||||
private:
|
||||
bool mCaseInsensitive;
|
||||
bool mIniReaded;
|
||||
|
||||
@@ -60,11 +60,10 @@ bool IniFile::loadFromMemory( const Uint8* RAWData, const Uint32& size ) {
|
||||
std::string myfile;
|
||||
myfile.assign( reinterpret_cast<const char*> (RAWData), size );
|
||||
|
||||
clear();
|
||||
mLines.clear();
|
||||
mLines = String::split( myfile );
|
||||
|
||||
mIniReaded = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,11 +80,10 @@ bool IniFile::loadFromFile( const std::string& iniPath ) {
|
||||
|
||||
f.read( (char*)&myfile[0], f.getSize() );
|
||||
|
||||
clear();
|
||||
mLines.clear();
|
||||
mLines = String::split( myfile );
|
||||
|
||||
mIniReaded = false;
|
||||
|
||||
return true;
|
||||
} else if ( PackManager::instance()->isFallbackToPacksActive() ) {
|
||||
std::string tPath( iniPath );
|
||||
@@ -421,13 +419,6 @@ bool IniFile::deleteKey ( std::string const keyname ) {
|
||||
if ( keyID == noID )
|
||||
return false;
|
||||
|
||||
// Now hopefully this destroys the vector lists within mKeys.
|
||||
// Looking at <vector> source, this should be the case using the destructor.
|
||||
// If not, I may have to do it explicitly. Memory leak check should tell.
|
||||
// memleak_test.cpp shows that the following not required.
|
||||
//mKeys[keyID].names.clear();
|
||||
//mKeys[keyID].values.clear();
|
||||
|
||||
std::vector<std::string>::iterator npos = mNames.begin() + keyID;
|
||||
std::vector<key>::iterator kpos = mKeys.begin() + keyID;
|
||||
mNames.erase ( npos, npos + 1 );
|
||||
@@ -437,12 +428,7 @@ bool IniFile::deleteKey ( std::string const keyname ) {
|
||||
}
|
||||
|
||||
void IniFile::clear() {
|
||||
// This loop not needed. The vector<> destructor seems to do
|
||||
// all the work itself. memleak_test.cpp shows this.
|
||||
//for ( unsigned i = 0; i < mKeys.size(); ++i) {
|
||||
// mKeys[i].names.clear();
|
||||
// mKeys[i].values.clear();
|
||||
//}
|
||||
mIniReaded = false;
|
||||
mNames.clear();
|
||||
mKeys.clear();
|
||||
mComments.clear();
|
||||
|
||||
Reference in New Issue
Block a user