many helper functions

This commit is contained in:
amannb 2011-10-25 11:47:23 -07:00 committed by Bernhard Amann
parent 3654060246
commit d7a3b85fcd
6 changed files with 245 additions and 31 deletions

View file

@ -32,4 +32,35 @@ bool InputReader::Init(string arg_source, int arg_num_fields,
void InputReader::Finish() {
DoFinish();
}
}
bool InputReader::Update() {
return DoUpdate();
}
// stolen from logwriter
const char* InputReader::Fmt(const char* format, ...)
{
if ( ! buf )
buf = (char*) malloc(buf_len);
va_list al;
va_start(al, format);
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*) realloc(buf, buf_len);
// Is it portable to restart?
va_start(al, format);
n = safe_vsnprintf(buf, buf_len, format, al);
va_end(al);
}
return buf;
}