mdbx-windows: refine debug-logging.

This commit is contained in:
Leonid Yuriev
2018-10-05 15:41:27 +03:00
parent 0f82db941b
commit 83f3d820f1
3 changed files with 44 additions and 7 deletions

View File

@@ -193,11 +193,9 @@ __cold void mdbx_panic(const char *fmt, ...) {
/*----------------------------------------------------------------------------*/
#ifndef mdbx_asprintf
int mdbx_asprintf(char **strp, const char *fmt, ...) {
va_list ap, ones;
va_start(ap, fmt);
#ifndef mdbx_vasprintf
int mdbx_vasprintf(char **strp, const char *fmt, va_list ap) {
va_list ones;
va_copy(ones, ap);
#ifdef _MSC_VER
int needed = _vscprintf(fmt, ap);
@@ -207,7 +205,6 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
#else
#error FIXME
#endif
va_end(ap);
if (unlikely(needed < 0 || needed >= INT_MAX)) {
*strp = nullptr;
@@ -218,7 +215,11 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
*strp = malloc(needed + 1);
if (unlikely(*strp == nullptr)) {
va_end(ones);
#if defined(_WIN32) || defined(_WIN64)
SetLastError(MDBX_ENOMEM);
#else
errno = MDBX_ENOMEM;
#endif
return -1;
}
@@ -237,6 +238,16 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
}
return actual;
}
#endif /* mdbx_vasprintf */
#ifndef mdbx_asprintf
int mdbx_asprintf(char **strp, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int rc = mdbx_vasprintf(strp, fmt, ap);
va_end(ap);
return rc;
}
#endif /* mdbx_asprintf */
#ifndef mdbx_memalign_alloc