From cdbb0722f642faa9f8d6e64f552a1e620f2b023e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 22 May 2013 03:02:39 -0700 Subject: 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. --- Alc/helpers.c | 17 +++++------------ 1 file 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); } -- cgit v1.2.3