mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
parent
f280dd4de7
commit
94b192b134
@ -37,14 +37,16 @@ class OutputDevice : public PdfOutputDevice {
|
||||
#ifdef _MSC_VER
|
||||
return _vscprintf(pszFormat, args);
|
||||
#else
|
||||
char buf[10];
|
||||
int res;
|
||||
res = vsnprintf(buf, 1, pszFormat, args);
|
||||
if (res < 0) {
|
||||
PyErr_SetString(PyExc_Exception, "Something bad happened while calling vsnprintf to get buffer length");
|
||||
throw pyerr();
|
||||
char *buf;
|
||||
int res, len=1024;
|
||||
while(true) {
|
||||
buf = new (std::nothrow) char[len];
|
||||
if (buf == NULL) { PyErr_NoMemory(); throw pyerr(); }
|
||||
res = vsnprintf(buf, len, pszFormat, args);
|
||||
delete[] buf;
|
||||
if (res >= 0) return res + 1;
|
||||
len *= 2;
|
||||
}
|
||||
return static_cast<long>(res+1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user