mirror of
https://github.com/isar/libmdbx.git
synced 2025-11-07 07:18:56 +08:00
mdbx-windows: refine debug-logging.
This commit is contained in:
23
src/osal.c
23
src/osal.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user