mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +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);
|
||||
#ifdef _MSC_VER
|
||||
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
|
||||
int needed = vsnprintf(nullptr, 0, fmt, ap);
|
||||
#else
|
||||
@ -117,9 +117,7 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
int actual = vsnprintf_s(*strp, needed + 1, _TRUNCATE, fmt, ones);
|
||||
#elif defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
||||
#if defined(vsnprintf) || defined(_BSD_SOURCE) || _XOPEN_SOURCE >= 500 || \
|
||||
defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L
|
||||
int actual = vsnprintf(*strp, needed + 1, fmt, ones);
|
||||
#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_clear(MDB_env *env);
|
||||
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…
Reference in New Issue
Block a user