diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-13 10:00:41 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-14 23:22:29 +0200 |
commit | aa5a8fe28a224fd581b6053e4a5ce38f3e1a9694 (patch) | |
tree | 3641fec62fd2f0969ce0ac06b4f7670d7e43c9f4 /src/newgrf_profiling.cpp | |
parent | 297d6e20bf0467d2a42e49bee291829ce3bb7c58 (diff) | |
download | openttd-aa5a8fe28a224fd581b6053e4a5ce38f3e1a9694.tar.xz |
Codechange: use thread safe time functions
Functions like localtime, gmtime and asctime are not thread safe as they (might) reuse the same buffer. So use the safer _s/_r variant for localtime and gmtime, and use strftime in favour of asctime.
Diffstat (limited to 'src/newgrf_profiling.cpp')
-rw-r--r-- | src/newgrf_profiling.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/newgrf_profiling.cpp b/src/newgrf_profiling.cpp index 8ec8cff54..27a1bc80e 100644 --- a/src/newgrf_profiling.cpp +++ b/src/newgrf_profiling.cpp @@ -13,9 +13,9 @@ #include "string_func.h" #include "console_func.h" #include "spritecache.h" +#include "walltime_func.h" #include <chrono> -#include <time.h> std::vector<NewGRFProfiler> _newgrf_profilers; @@ -130,10 +130,8 @@ void NewGRFProfiler::Abort() */ std::string NewGRFProfiler::GetOutputFilename() const { - time_t write_time = time(nullptr); - char timestamp[16] = {}; - strftime(timestamp, lengthof(timestamp), "%Y%m%d-%H%M", localtime(&write_time)); + LocalTime::Format(timestamp, lastof(timestamp), "%Y%m%d-%H%M"); char filepath[MAX_PATH] = {}; seprintf(filepath, lastof(filepath), "%sgrfprofile-%s-%08X.csv", FiosGetScreenshotDir(), timestamp, BSWAP32(this->grffile->grfid)); |