mirror of https://github.com/OpenTTD/OpenTTD
Codechange: move to std::string over stredup + free
parent
2a2443dd01
commit
714ff35e9d
|
@ -58,10 +58,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
|
|
||||||
CrashLog::InitialiseCrashLog();
|
CrashLog::InitialiseCrashLog();
|
||||||
|
|
||||||
/* Convert the command line to UTF-8. We need a dedicated buffer
|
/* Convert the command line to UTF-8. */
|
||||||
* for this because argv[] points into this buffer and this needs to
|
std::string cmdline = FS2OTTD(GetCommandLine());
|
||||||
* be available between subsequent calls to FS2OTTD(). */
|
|
||||||
char *cmdline = stredup(FS2OTTD(GetCommandLine()).c_str());
|
|
||||||
|
|
||||||
/* Set the console codepage to UTF-8. */
|
/* Set the console codepage to UTF-8. */
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
@ -76,7 +74,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
SetRandomSeed(GetTickCount());
|
SetRandomSeed(GetTickCount());
|
||||||
|
|
||||||
char *argv[64]; // max 64 command line arguments
|
char *argv[64]; // max 64 command line arguments
|
||||||
int argc = ParseCommandLine(cmdline, argv, lengthof(argv));
|
int argc = ParseCommandLine(cmdline.data(), argv, lengthof(argv));
|
||||||
|
|
||||||
/* Make sure our arguments contain only valid UTF-8 characters. */
|
/* Make sure our arguments contain only valid UTF-8 characters. */
|
||||||
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
|
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
|
||||||
|
@ -86,6 +84,5 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
/* Restore system timer resolution. */
|
/* Restore system timer resolution. */
|
||||||
timeEndPeriod(1);
|
timeEndPeriod(1);
|
||||||
|
|
||||||
free(cmdline);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue