summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-22 03:02:39 -0700
committerChris Robinson <[email protected]>2013-05-22 03:02:39 -0700
commitcdbb0722f642faa9f8d6e64f552a1e620f2b023e (patch)
tree2df1d340e6a4db555830721c99738e2773be3737
parent2eb8a520d434f002928798fe2e08a6ff173dfa01 (diff)
Avoid using a temp buffer for al_print
It's now using two *printf calls, which unfortuantely means there could be a race between the two and cause the message to break up if something else tries to print to the same file. This shouldn't really be a big deal since al_print isn't used that often, and it now allows for lines of practically unlimited length.
-rw-r--r--Alc/helpers.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 6358f044..36934ca4 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -449,20 +449,13 @@ void *GetSymbol(void *handle, const char *name)
void al_print(const char *type, const char *func, const char *fmt, ...)
{
- char str[256];
- int i;
+ va_list ap;
- i = snprintf(str, sizeof(str), "AL lib: %s %s: ", type, func);
- if(i > 0 && (unsigned int)i < sizeof(str))
- {
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(str+i, sizeof(str)-i, fmt, ap);
- va_end(ap);
- }
- str[sizeof(str)-1] = 0;
+ va_start(ap, fmt);
+ fprintf(LogFile, "AL lib: %s %s: ", type, func);
+ vfprintf(LogFile, fmt, ap);
+ va_end(ap);
- fprintf(LogFile, "%s", str);
fflush(LogFile);
}