mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 14:08:20 +08:00
mdbx: use FormatMessage() for Windows.
This commit is contained in:
parent
f91218bda4
commit
326dea8bc1
2
TODO.md
2
TODO.md
@ -1,4 +1,4 @@
|
|||||||
- [ ] разделение errno и GetLastError()
|
- [x] разделение errno и GetLastError()
|
||||||
- [x] CI посредством AppVeyor
|
- [x] CI посредством AppVeyor
|
||||||
- [ ] uint32/uint64 в структурах
|
- [ ] uint32/uint64 в структурах
|
||||||
- [ ] правки API (много...)
|
- [ ] правки API (много...)
|
||||||
|
18
src/mdbx.c
18
src/mdbx.c
@ -763,10 +763,10 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) {
|
|||||||
if (!buflen)
|
if (!buflen)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
int rc = strerror_s(buf, buflen, errnum);
|
size_t size = FormatMessageA(
|
||||||
assert(rc == 0);
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||||
(void)rc;
|
errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, buflen, NULL);
|
||||||
return buf;
|
return size ? buf : NULL;
|
||||||
#elif defined(_GNU_SOURCE)
|
#elif defined(_GNU_SOURCE)
|
||||||
/* GNU-specific */
|
/* GNU-specific */
|
||||||
msg = strerror_r(errnum, buf, buflen);
|
msg = strerror_r(errnum, buf, buflen);
|
||||||
@ -792,10 +792,12 @@ const char *__cold mdbx_strerror(int errnum) {
|
|||||||
if (!msg) {
|
if (!msg) {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
static __thread char buffer[1024];
|
static __thread char buffer[1024];
|
||||||
int rc = strerror_s(buffer, sizeof(buffer), errnum);
|
size_t size = FormatMessageA(
|
||||||
assert(rc == 0);
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||||
(void)rc;
|
errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer,
|
||||||
msg = buffer;
|
sizeof(buffer), NULL);
|
||||||
|
if (size)
|
||||||
|
msg = buffer;
|
||||||
#else
|
#else
|
||||||
msg = strerror(errnum);
|
msg = strerror(errnum);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user