Comment Re:char Str[255] (Score 1) 683
I realise you probably can't use this trick, but I ran into some of the same issue when building my own functions that used varargs... How to allocate enough space for the return buffer w/o knowing how much space you'd need....
Luckily, you can pass a size to vsnprintf(), and it will return the number of bytes needed if it's more than 'size':
void sys_log (bool s_time, Log_Type type, Log_Level lev, char *fmt,
char buf1[2];
char *buf;
va_list args;
va_start (args, fmt);
num = vsnprintf (buf1, 1, fmt, args);
buf = malloc (num + 2);
vsnprintf (buf, num + 1, fmt, args);
va_end (args);
}