Skip to content

Commit

Permalink
Remove bad locking from Win32OutputError
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfleury committed Jul 7, 2020
1 parent d9df978 commit 680b638
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions source/win32/win32_utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,23 @@ Win32HeapFree(void *data)
internal void
Win32OutputError(char *title, char *format, ...)
{
local_persist volatile LONG locked = 0;
va_list args;
va_start(args, format);
u32 required_characters = vsnprintf(0, 0, format, args)+1;
va_end(args);

while(locked);
InterlockedExchange(&locked, 1);
char text[4096] = {0};
if(required_characters > 4096)
{
va_list args;
va_start(args, format);
u32 required_characters = vsnprintf(0, 0, format, args)+1;
va_end(args);

local_persist char text[4096] = {0};

if(required_characters > 4096)
{
required_characters = 4096;
}

va_start(args, format);
vsnprintf(text, required_characters, format, args);
va_end(args);

text[required_characters-1] = 0;

MessageBoxA(0, text, title, MB_OK);
required_characters = 4096;
}
InterlockedExchange(&locked, 0);

va_start(args, format);
vsnprintf(text, required_characters, format, args);
va_end(args);

text[required_characters-1] = 0;
MessageBoxA(0, text, title, MB_OK);
}

internal void
Expand Down

0 comments on commit 680b638

Please sign in to comment.