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