mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
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:
parent
50e307b4b7
commit
452c61db7a
1 changed files with 7 additions and 11 deletions
|
@ -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. */
|
||||
|
|
Loading…
Reference in a new issue