mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-03 23:49:44 +00:00
avoid using LocalFree on FormatMessageA buffer (#3772)
* avoid using localfree for FormatMessageA buffer because it is only supported on windows 10 Co-authored-by: Ori Levari <orlevari@microsoft.com>
This commit is contained in:
parent
f68a326bd9
commit
ad63e2593d
1 changed files with 4 additions and 5 deletions
|
|
@ -178,11 +178,10 @@ inline OrtFileType DTToFileType(DWORD dwFileAttributes) {
|
|||
return OrtFileType::TYPE_REG;
|
||||
}
|
||||
inline std::string FormatErrorCode(DWORD dw) {
|
||||
char* lpMsgBuf;
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&lpMsgBuf, 0, NULL);
|
||||
std::string s(lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
static const DWORD bufferLength = 64 * 1024;
|
||||
std::string s(bufferLength, '\0');
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)s.data(), bufferLength / sizeof(TCHAR), NULL);
|
||||
return s;
|
||||
}
|
||||
template <typename T>
|
||||
|
|
|
|||
Loading…
Reference in a new issue