Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives
This commit is contained in:
@@ -1345,12 +1345,11 @@ StringList GetGRFPresetList()
|
||||
*/
|
||||
GRFConfig *LoadGRFPresetFromConfig(const char *config_name)
|
||||
{
|
||||
size_t len = strlen(config_name) + 8;
|
||||
char *section = (char*)alloca(len);
|
||||
seprintf(section, section + len - 1, "preset-%s", config_name);
|
||||
std::string section("preset-");
|
||||
section += config_name;
|
||||
|
||||
ConfigIniFile ini(_config_file);
|
||||
GRFConfig *config = GRFLoadConfig(ini, section, false);
|
||||
GRFConfig *config = GRFLoadConfig(ini, section.c_str(), false);
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -1363,12 +1362,11 @@ GRFConfig *LoadGRFPresetFromConfig(const char *config_name)
|
||||
*/
|
||||
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
|
||||
{
|
||||
size_t len = strlen(config_name) + 8;
|
||||
char *section = (char*)alloca(len);
|
||||
seprintf(section, section + len - 1, "preset-%s", config_name);
|
||||
std::string section("preset-");
|
||||
section += config_name;
|
||||
|
||||
ConfigIniFile ini(_config_file);
|
||||
GRFSaveConfig(ini, section, config);
|
||||
GRFSaveConfig(ini, section.c_str(), config);
|
||||
ini.SaveToDisk(_config_file);
|
||||
}
|
||||
|
||||
@@ -1378,12 +1376,11 @@ void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
|
||||
*/
|
||||
void DeleteGRFPresetFromConfig(const char *config_name)
|
||||
{
|
||||
size_t len = strlen(config_name) + 8;
|
||||
char *section = (char*)alloca(len);
|
||||
seprintf(section, section + len - 1, "preset-%s", config_name);
|
||||
std::string section("preset-");
|
||||
section += config_name;
|
||||
|
||||
ConfigIniFile ini(_config_file);
|
||||
ini.RemoveGroup(section);
|
||||
ini.RemoveGroup(section.c_str());
|
||||
ini.SaveToDisk(_config_file);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user