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/debug.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/debug.cpp')
-rw-r--r-- | src/debug.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index 25a0f1a82..39c695e03 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -19,7 +19,7 @@ #include "os/windows/win32.h" #endif -#include <time.h> +#include "walltime_func.h" #include "network/network_admin.h" SOCKET _debug_socket = INVALID_SOCKET; @@ -248,8 +248,7 @@ const char *GetLogPrefix() { static char _log_prefix[24]; if (_settings_client.gui.show_date_in_logs) { - time_t cur_time = time(nullptr); - strftime(_log_prefix, sizeof(_log_prefix), "[%Y-%m-%d %H:%M:%S] ", localtime(&cur_time)); + LocalTime::Format(_log_prefix, lastof(_log_prefix), "[%Y-%m-%d %H:%M:%S] "); } else { *_log_prefix = '\0'; } |