Codechange: [Win32] Use a local buffer to store the output text of DEBUG() to make the call thread-safe.

This commit is contained in:
Michael Lutz 2018-05-20 03:15:22 +02:00
parent e1a164b531
commit 3fc9c9522d
1 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,10 @@
#include "fileio_func.h"
#include "settings_type.h"
#if defined(WIN32) || defined(WIN64)
#include "os/windows/win32.h"
#endif
#include <time.h>
#if defined(ENABLE_NETWORK)
@ -136,7 +140,9 @@ static void debug_print(const char *dbg, const char *buf)
char buffer[512];
seprintf(buffer, lastof(buffer), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf);
#if defined(WIN32) || defined(WIN64)
_fputts(OTTD2FS(buffer, true), stderr);
TCHAR system_buf[512];
convert_to_fs(buffer, system_buf, lengthof(system_buf), true);
_fputts(system_buf, stderr);
#else
fputs(buffer, stderr);
#endif