OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PlatformSTL_h | 5 #ifndef PlatformSTL_h |
6 #define PlatformSTL_h | 6 #define PlatformSTL_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #define PLATFORM_EXPORT | 10 #define PLATFORM_EXPORT |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 | 283 |
284 #endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) | 284 #endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) |
285 | 285 |
286 template <typename T> | 286 template <typename T> |
287 std::unique_ptr<T> wrapUnique(T* ptr) | 287 std::unique_ptr<T> wrapUnique(T* ptr) |
288 { | 288 { |
289 return std::unique_ptr<T>(ptr); | 289 return std::unique_ptr<T>(ptr); |
290 } | 290 } |
291 | 291 |
| 292 // emulate snprintf() on windows, _snprintf() doesn't zero-terminate the buffer |
| 293 // on overflow... |
| 294 // VS 2015 added a standard conform snprintf |
| 295 #if defined(_WIN32) && defined( _MSC_VER ) && (_MSC_VER < 1900) |
| 296 #include <stdarg.h> |
| 297 namespace std { |
| 298 |
| 299 inline static int snprintf(char *buffer, size_t n, const char *format, ...) |
| 300 { |
| 301 va_list argp; |
| 302 va_start(argp, format); |
| 303 int ret = _vscprintf(format, argp); |
| 304 vsnprintf_s(buffer, n, _TRUNCATE, format, argp); |
| 305 va_end(argp); |
| 306 return ret; |
| 307 } |
| 308 } // namespace std |
| 309 #endif // (_WIN32) && defined( _MSC_VER ) && (_MSC_VER < 1900) |
| 310 |
292 #endif // PlatformSTL_h | 311 #endif // PlatformSTL_h |
OLD | NEW |