From d67071cf0e53e0c6d6429d742ff5213da3dbba5e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 5 Jul 2015 19:22:21 -0500 Subject: [PATCH] Implement a new safer Limelog for Windows --- limelight-common/Platform.c | 17 +++++++++++++---- limelight-common/Platform.h | 5 ++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/limelight-common/Platform.c b/limelight-common/Platform.c index 05a900c..3d58bdd 100644 --- a/limelight-common/Platform.c +++ b/limelight-common/Platform.c @@ -1,13 +1,22 @@ #include "PlatformThreads.h" #include "Platform.h" -#if defined(LC_WINDOWS) -WCHAR DbgBuf[512]; -#endif - int initializePlatformSockets(void); void cleanupPlatformSockets(void); +#if defined(LC_WINDOWS) +void LimelogWindows(char* Format, ...) { + va_list va; + char buffer[1024]; + + va_start(va, Format); + vsprintf(buffer, Format, va); + va_end(va); + + OutputDebugStringA(buffer); +} +#endif + #if defined(LC_WINDOWS) PLT_MUTEX thread_list_lock; PLT_THREAD *thread_head; diff --git a/limelight-common/Platform.h b/limelight-common/Platform.h index 7ff23de..2418c96 100644 --- a/limelight-common/Platform.h +++ b/limelight-common/Platform.h @@ -29,10 +29,9 @@ #include "Limelight.h" #if defined(LC_WINDOWS) -extern WCHAR DbgBuf[512]; +void LimelogWindows(char* Format, ...); #define Limelog(s, ...) \ - swprintf(DbgBuf, sizeof(DbgBuf) / sizeof(WCHAR), L ## s, ##__VA_ARGS__); \ - OutputDebugStringW(DbgBuf) + LimelogWindows(s, ##__VA_ARGS__) #else #define Limelog(s, ...) \ fprintf(stderr, s, ##__VA_ARGS__)