From 70de70bdcddf9c2fbb79fd3c7520a85f34aed466 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 18 Jun 2023 19:24:12 +0200 Subject: [PATCH] Codechange: refactor code to remove need for stredup --- src/console_cmds.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index ceb11f5b49..62a22037a3 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1275,16 +1275,14 @@ DEF_CONSOLE_CMD(ConStartAI) * try again with the assumption everything right of the dot is * the version the user wants to load. */ if (!config->HasScript()) { - char *name = stredup(argv[1]); - char *e = strrchr(name, '.'); + const char *e = strrchr(argv[1], '.'); if (e != nullptr) { - *e = '\0'; + size_t name_length = e - argv[1]; 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()) {