Codechange: refactor code to remove need for stredup

This commit is contained in:
Rubidium 2023-06-18 19:24:12 +02:00 committed by rubidium42
parent 74924c8186
commit 70de70bdcd
1 changed files with 3 additions and 5 deletions

View File

@ -1275,16 +1275,14 @@ DEF_CONSOLE_CMD(ConStartAI)
* try again with the assumption everything right of the dot is * try again with the assumption everything right of the dot is
* the version the user wants to load. */ * the version the user wants to load. */
if (!config->HasScript()) { if (!config->HasScript()) {
char *name = stredup(argv[1]); const char *e = strrchr(argv[1], '.');
char *e = strrchr(name, '.');
if (e != nullptr) { if (e != nullptr) {
*e = '\0'; size_t name_length = e - argv[1];
e++; e++;
int version = atoi(e); int version = atoi(e);
config->Change(name, version, true); config->Change(std::string(argv[1], name_length), version, true);
} }
free(name);
} }
if (!config->HasScript()) { if (!config->HasScript()) {