Only process va_lists once (fixes crash on x86_64 gcc 4.1)

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2337 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2006-05-01 02:14:36 +00:00
parent b9c4ec6726
commit 1afadf9968
+12 -6
View File
@@ -17,6 +17,8 @@
#include "uqmlog.h" #include "uqmlog.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include "libs/threadlib.h" #include "libs/threadlib.h"
@@ -192,10 +194,12 @@ log_setOutput (FILE *out)
void void
log_addV (log_Level level, const char *fmt, va_list list) log_addV (log_Level level, const char *fmt, va_list list)
{ {
log_Entry full_msg;
vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list);
if ((int)level <= maxStreamLevel) if ((int)level <= maxStreamLevel)
{ {
vfprintf (streamOut, fmt, list); fprintf (streamOut, "%s\n", full_msg);
fputc ('\n', streamOut);
} }
if ((int)level <= maxLevel) if ((int)level <= maxLevel)
@@ -205,7 +209,7 @@ log_addV (log_Level level, const char *fmt, va_list list)
queueNonThreaded (); queueNonThreaded ();
slot = acquireSlot (); slot = acquireSlot ();
vsnprintf (queue[slot], sizeof (queue[0]) - 1, fmt, list); snprintf (queue[slot], sizeof (queue[0]) - 1, "%s", full_msg);
} }
} }
@@ -225,15 +229,17 @@ log_add (log_Level level, const char *fmt, ...)
void void
log_add_nothreadV (log_Level level, const char *fmt, va_list list) log_add_nothreadV (log_Level level, const char *fmt, va_list list)
{ {
log_Entry full_msg;
vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list);
if ((int)level <= maxStreamLevel) if ((int)level <= maxStreamLevel)
{ {
vfprintf (streamOut, fmt, list); fprintf (streamOut, "%s\n", full_msg);
fputc ('\n', streamOut);
} }
if ((int)level <= maxLevel) if ((int)level <= maxLevel)
{ {
vsnprintf (msgNoThread, sizeof (msgNoThread) - 1, fmt, list); snprintf (msgNoThread, sizeof (msgNoThread) - 1, "%s", full_msg);
noThreadReady = true; noThreadReady = true;
} }
} }