I'm working on porting the nebula device to 64-bit linux and I've hit a snag with the logger. It has a printf style function that handles the logging:
Code:
void
nDefaultLogHandler::PutLineBuffer(const char* msg, va_list argList)
{
n_assert(msg);
int n, size = 100;
static char* staticArray = new char [10000];
#ifdef __WIN32__
n = _vsnprintf (staticArray, 10000, msg, argList);
#else
n = vsnprintf (staticArray, 10000, msg, argList);
#endif
if( n > -1 && n < 10000 )
this->lineBuffer.Put( staticArray );
}
This compiles fine, but when I run it I get a segfault:
#0 0x000000397ed745e0 in ?? () from /lib64/libc.so.6
#1 0x000000397ed4503b in _IO_vfprintf_internal (s=0x7ffffff924b0, format=Variable "format" is not available.
) at vfprintf.c:1559
#2 0x000000397ed65c1a in _IO_vsnprintf (string=0x12f4fd0 "", maxlen=Variable "maxlen" is not available.
) at vsnprintf.c:120
#3 0x00002aaaaaafcc50 in nDefaultLogHandler::PutLineBuffer (this=0x503950, msg=0x2aaab1730290 "%s just redefined type from %s -> %s\n",
argList=0x7ffffff926d0) at kernel/ndefaultloghandler.cc:103
I tried changing the whole thing to a more standard va_start vsnprintf va_end style, but I just get type conversion errors between va_arg and char. Does anyone know a portable way to do the vsnprintf?