Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives

This commit is contained in:
Charles Pigott
2021-05-01 21:06:17 +01:00
committed by PeterN
parent b19f42ecd9
commit b282664242
18 changed files with 135 additions and 122 deletions

View File

@@ -1063,8 +1063,8 @@ char *GenerateTownNameString(char *buf, const char *last, size_t lang, uint32 se
const TownNameGeneratorParams *par = &_town_name_generators[lang];
if (last >= buf + par->min) return par->proc(buf, last, seed);
char *buffer = AllocaM(char, par->min + 1);
par->proc(buffer, buffer + par->min, seed);
std::string buffer(par->min + 1, '\0');
par->proc(buffer.data(), buffer.data() + par->min, seed);
return strecpy(buf, buffer, last);
return strecpy(buf, buffer.c_str(), last);
}