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':
On the other hand, the BREST reactor (a Russian lead-bismuth design) is just great. Can survive on just convection cooling, uses an unreactive moderator, great temperature range, easy maintainance, low waste, anti-proliferation, etc. What isn't there to like?:)
Most people won't support this, if for nothing else, then because it's Russian...
(Just an observation, not intended as inflammatory)
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);
}
(Just an observation, not intended as inflammatory)
- d.
According to the police scanner just now, blood donations can be given at any NYC hospital.