mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Merge topic/actor-system throug a squashed commit.
This commit is contained in:
parent
7a6f5020f6
commit
fe7e1ee7f0
466 changed files with 12559 additions and 9655 deletions
22
src/util.cc
22
src/util.cc
|
@ -542,7 +542,7 @@ const char* fmt_bytes(const char* data, int len)
|
|||
return buf;
|
||||
}
|
||||
|
||||
const char* fmt(const char* format, ...)
|
||||
const char* fmt(const char* format, va_list al)
|
||||
{
|
||||
static char* buf = 0;
|
||||
static unsigned int buf_len = 1024;
|
||||
|
@ -550,28 +550,34 @@ const char* fmt(const char* format, ...)
|
|||
if ( ! buf )
|
||||
buf = (char*) safe_malloc(buf_len);
|
||||
|
||||
va_list al;
|
||||
va_start(al, format);
|
||||
va_list alc;
|
||||
va_copy(alc, al);
|
||||
int n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
va_end(al);
|
||||
|
||||
if ( (unsigned int) n >= buf_len )
|
||||
{ // Not enough room, grow the buffer.
|
||||
buf_len = n + 32;
|
||||
buf = (char*) safe_realloc(buf, buf_len);
|
||||
|
||||
// Is it portable to restart?
|
||||
va_start(al, format);
|
||||
n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
va_end(al);
|
||||
n = safe_vsnprintf(buf, buf_len, format, alc);
|
||||
|
||||
if ( (unsigned int) n >= buf_len )
|
||||
reporter->InternalError("confusion reformatting in fmt()");
|
||||
}
|
||||
|
||||
va_end(alc);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* fmt(const char* format, ...)
|
||||
{
|
||||
va_list al;
|
||||
va_start(al, format);
|
||||
auto rval = fmt(format, al);
|
||||
va_end(al);
|
||||
return rval;
|
||||
}
|
||||
|
||||
const char* fmt_access_time(double t)
|
||||
{
|
||||
static char buf[256];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue