mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:14:12 +08:00
mdbx: snprintf/vsnprintf stub for MSC.
This commit is contained in:
parent
ab4597cedc
commit
6d507233cc
@ -97,7 +97,7 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
|
|||||||
va_copy(ones, ap);
|
va_copy(ones, ap);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
int needed = _vscprintf(fmt, ap);
|
int needed = _vscprintf(fmt, ap);
|
||||||
#elif defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
#elif defined(vsnprintf) || defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
||||||
defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L
|
defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L
|
||||||
int needed = vsnprintf(nullptr, 0, fmt, ap);
|
int needed = vsnprintf(nullptr, 0, fmt, ap);
|
||||||
#else
|
#else
|
||||||
@ -117,9 +117,7 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(vsnprintf) || defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
||||||
int actual = vsnprintf_s(*strp, needed + 1, _TRUNCATE, fmt, ones);
|
|
||||||
#elif defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
|
||||||
defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L
|
defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L
|
||||||
int actual = vsnprintf(*strp, needed + 1, fmt, ones);
|
int actual = vsnprintf(*strp, needed + 1, fmt, ones);
|
||||||
#else
|
#else
|
||||||
|
14
src/osal.h
14
src/osal.h
@ -421,3 +421,17 @@ void mdbx_txn_unlock(MDB_env *env);
|
|||||||
int mdbx_rpid_set(MDB_env *env);
|
int mdbx_rpid_set(MDB_env *env);
|
||||||
int mdbx_rpid_clear(MDB_env *env);
|
int mdbx_rpid_clear(MDB_env *env);
|
||||||
int mdbx_rpid_check(MDB_env *env, mdbx_pid_t pid);
|
int mdbx_rpid_check(MDB_env *env, mdbx_pid_t pid);
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifndef snprintf
|
||||||
|
#define snprintf(buffer, buffer_size, format, ...) \
|
||||||
|
_snprintf_s(buffer, buffer_size, _TRUNCATE, format, __VA_ARGS__)
|
||||||
|
#endif /* snprintf */
|
||||||
|
|
||||||
|
#ifndef vsnprintf
|
||||||
|
#define vsnprintf(buffer, buffer_size, format, args) \
|
||||||
|
_vsnprintf_s(buffer, buffer_size, _TRUNCATE, format, args)
|
||||||
|
#endif /* vsnprintf */
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user