setsys_settings_items: Simplify buffer management in LoadConfiguration()

We can use a std::string here instead of setting up a scope guard and
manual allocations. We also don't need to care about null-termination,
as c_str() will automatically ensure this is done when passing it into
ini_parse_string().
This commit is contained in:
Lioncash 2019-06-03 20:54:24 -04:00
parent 50e307b4b7
commit 452c61db7a

View file

@ -254,20 +254,16 @@ void SettingsItemManager::LoadConfiguration() {
};
/* Allocate buffer. */
char *config_buf = new char[0x10000];
std::memset(config_buf, 0, 0x10000);
ON_SCOPE_EXIT {
delete[] config_buf;
};
std::string config_buf(0xFFFF, '\0');
/* Read from file. */
if (R_SUCCEEDED(rc)) {
size_t actual_size;
rc = fsFileRead(&config_file, 0, config_buf, 0xFFFF, FS_READOPTION_NONE, &actual_size);
rc = fsFileRead(&config_file, 0, config_buf.data(), config_buf.size(), FS_READOPTION_NONE, &actual_size);
}
if (R_SUCCEEDED(rc)) {
ini_parse_string(config_buf, SettingsItemIniHandler, &rc);
ini_parse_string(config_buf.c_str(), SettingsItemIniHandler, &rc);
}
/* Report error if we encountered one. */