mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:24:14 +08:00
mdbx-windows: avoid use strerror() from CRT.
9 of 17 for https://github.com/leo-yuriev/libmdbx/issues/43 Change-Id: I53b770e911ff8e7d4e084a323a374d09ea516986
This commit is contained in:
parent
4dea5c2719
commit
80ccb31008
@ -1325,7 +1325,7 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) {
|
|||||||
if (!msg) {
|
if (!msg) {
|
||||||
if (!buflen || buflen > INT_MAX)
|
if (!buflen || buflen > INT_MAX)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef _MSC_VER
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
size_t size = FormatMessageA(
|
size_t size = FormatMessageA(
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||||
errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, (DWORD)buflen,
|
errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, (DWORD)buflen,
|
||||||
@ -1354,7 +1354,7 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) {
|
|||||||
const char *__cold mdbx_strerror(int errnum) {
|
const char *__cold mdbx_strerror(int errnum) {
|
||||||
const char *msg = __mdbx_strerr(errnum);
|
const char *msg = __mdbx_strerr(errnum);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
#ifdef _MSC_VER
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
size_t size = FormatMessageA(
|
size_t size = FormatMessageA(
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||||
@ -4521,7 +4521,7 @@ static int mdbx_page_flush(MDBX_txn *txn, pgno_t keep) {
|
|||||||
/* Write previous page(s) */
|
/* Write previous page(s) */
|
||||||
rc = mdbx_pwritev(env->me_fd, iov, n, wpos, wsize);
|
rc = mdbx_pwritev(env->me_fd, iov, n, wpos, wsize);
|
||||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||||
mdbx_debug("Write error: %s", strerror(rc));
|
mdbx_debug("Write error: %s", mdbx_strerror(rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -203,7 +203,8 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (freopen(optarg, "w", stdout) == NULL) {
|
if (freopen(optarg, "w", stdout) == NULL) {
|
||||||
fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, strerror(errno));
|
fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg,
|
||||||
|
mdbx_strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -340,7 +340,8 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (freopen(optarg, "r", stdin) == NULL) {
|
if (freopen(optarg, "r", stdin) == NULL) {
|
||||||
fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, strerror(errno));
|
fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg,
|
||||||
|
mdbx_strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user