Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / third_party / upb / upb / port.c
1
2 #include "upb/upb.h"
3 #include "upb/port_def.inc"
4
5 #ifdef UPB_MSVC_VSNPRINTF
6 /* Visual C++ earlier than 2015 doesn't have standard C99 snprintf and
7  * vsnprintf. To support them, missing functions are manually implemented
8  * using the existing secure functions. */
9 int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg) {
10   if (!s) {
11     return _vscprintf(format, arg);
12   }
13   int ret = _vsnprintf_s(s, n, _TRUNCATE, format, arg);
14   if (ret < 0) {
15         ret = _vscprintf(format, arg);
16   }
17   return ret;
18 }
19
20 int msvc_snprintf(char* s, size_t n, const char* format, ...) {
21   va_list arg;
22   va_start(arg, format);
23   int ret = msvc_vsnprintf(s, n, format, arg);
24   va_end(arg);
25   return ret;
26 }
27 #endif