1 #include "../git-compat-util.h"
4 * The size parameter specifies the available space, i.e. includes
5 * the trailing NUL byte; but Windows's vsnprintf expects the
6 * number of characters to write without the trailing NUL.
8 #ifndef SNPRINTF_SIZE_CORR
9 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4 || defined(_MSC_VER)
10 #define SNPRINTF_SIZE_CORR 1
12 #define SNPRINTF_SIZE_CORR 0
19 #define vsnprintf _vsnprintf
22 int git_vsnprintf(char *str
, size_t maxsize
, const char *format
, va_list ap
)
28 ret
= vsnprintf(str
, maxsize
-SNPRINTF_SIZE_CORR
, format
, ap
);
31 /* Windows does not NUL-terminate if result fills buffer */
43 str
= realloc(s
, maxsize
);
47 ret
= vsnprintf(str
, maxsize
-SNPRINTF_SIZE_CORR
, format
, ap
);
55 int git_snprintf(char *str
, size_t maxsize
, const char *format
, ...)
61 ret
= git_vsnprintf(str
, maxsize
, format
, ap
);