forked from coolwanglu/pdf2htmlEX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringFormatter.cc
More file actions
30 lines (24 loc) · 812 Bytes
/
Copy pathStringFormatter.cc
File metadata and controls
30 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <cstdarg>
#include <algorithm>
#include <cassert>
#include "StringFormatter.h"
namespace pdf2htmlEX {
StringFormatter::GuardedPointer StringFormatter::operator () (const char * format, ...)
{
assert((buf_cnt == 0) && "StringFormatter: buffer is reused!");
va_list vlist;
va_start(vlist, format);
int l = vsnprintf(&buf.front(), buf.capacity(), format, vlist);
va_end(vlist);
if(l >= (int)buf.capacity())
{
buf.reserve(std::max<long>((long)(l+1), (long)buf.capacity() * 2));
va_start(vlist, format);
l = vsnprintf(&buf.front(), buf.capacity(), format, vlist);
va_end(vlist);
}
assert(l >= 0); // we should fail when vsnprintf fail
assert(l < (int)buf.capacity());
return GuardedPointer(this);
}
} //namespace pdf2htmlEX