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:
Leonid Yuriev 2018-10-14 10:32:37 +03:00
parent 4dea5c2719
commit 80ccb31008
3 changed files with 7 additions and 5 deletions

View File

@ -1325,7 +1325,7 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) {
if (!msg) {
if (!buflen || buflen > INT_MAX)
return NULL;
#ifdef _MSC_VER
#if defined(_WIN32) || defined(_WIN64)
size_t size = FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
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 *msg = __mdbx_strerr(errnum);
if (!msg) {
#ifdef _MSC_VER
#if defined(_WIN32) || defined(_WIN64)
static char buffer[1024];
size_t size = FormatMessageA(
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) */
rc = mdbx_pwritev(env->me_fd, iov, n, wpos, wsize);
if (unlikely(rc != MDBX_SUCCESS)) {
mdbx_debug("Write error: %s", strerror(rc));
mdbx_debug("Write error: %s", mdbx_strerror(rc));
return rc;
}
n = 0;

View File

@ -203,7 +203,8 @@ int main(int argc, char *argv[]) {
break;
case 'f':
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);
}
break;

View File

@ -340,7 +340,8 @@ int main(int argc, char *argv[]) {
break;
case 'f':
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);
}
break;