summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/os_win/os_vsnprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/os_win/os_vsnprintf.c')
-rw-r--r--src/third_party/wiredtiger/src/os_win/os_vsnprintf.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/src/os_win/os_vsnprintf.c b/src/third_party/wiredtiger/src/os_win/os_vsnprintf.c
new file mode 100644
index 00000000000..1058203e326
--- /dev/null
+++ b/src/third_party/wiredtiger/src/os_win/os_vsnprintf.c
@@ -0,0 +1,31 @@
+/*-
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+#undef vsnprintf
+
+_Check_return_opt_ int __cdecl _wt_vsnprintf(
+ _Out_writes_(_MaxCount) char * _DstBuf,
+ _In_ size_t _MaxCount,
+ _In_z_ _Printf_format_string_ const char * _Format,
+ va_list _ArgList)
+{
+ int len;
+
+ len = (size_t)vsnprintf(_DstBuf, _MaxCount, _Format, _ArgList);
+
+ /*
+ * The MSVC implementation returns -1 on truncation instead of what
+ * it would have written. We could iteratively grow the buffer, or
+ * just ask us how big a buffer they would like.
+ */
+ if (len == -1)
+ len = _vscprintf(_Format, _ArgList) + 1;
+
+ return (len);
+}