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.
This commit is contained in:
+5
-12
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user