| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <malloc.h> // NOLINT | 10 #include <malloc.h> // NOLINT |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 va_list args_retry; | 256 va_list args_retry; |
| 257 va_copy(args_retry, args); | 257 va_copy(args_retry, args); |
| 258 written = _vscprintf(format, args_retry); | 258 written = _vscprintf(format, args_retry); |
| 259 if (written < 0) { | 259 if (written < 0) { |
| 260 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format); | 260 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format); |
| 261 } | 261 } |
| 262 va_end(args_retry); | 262 va_end(args_retry); |
| 263 } | 263 } |
| 264 // Make sure to zero-terminate the string if the output was | 264 // Make sure to zero-terminate the string if the output was |
| 265 // truncated or if there was an error. | 265 // truncated or if there was an error. |
| 266 if (written >= size) { | 266 // The static cast is safe here as we have already determined that 'written' |
| 267 // is >= 0. |
| 268 if (static_cast<size_t>(written) >= size) { |
| 267 str[size - 1] = '\0'; | 269 str[size - 1] = '\0'; |
| 268 } | 270 } |
| 269 return written; | 271 return written; |
| 270 } | 272 } |
| 271 | 273 |
| 272 | 274 |
| 273 bool OS::StringToInt64(const char* str, int64_t* value) { | 275 bool OS::StringToInt64(const char* str, int64_t* value) { |
| 274 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); | 276 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); |
| 275 int32_t base = 10; | 277 int32_t base = 10; |
| 276 char* endptr; | 278 char* endptr; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 329 } |
| 328 | 330 |
| 329 | 331 |
| 330 void OS::Exit(int code) { | 332 void OS::Exit(int code) { |
| 331 exit(code); | 333 exit(code); |
| 332 } | 334 } |
| 333 | 335 |
| 334 } // namespace dart | 336 } // namespace dart |
| 335 | 337 |
| 336 #endif // defined(TARGET_OS_WINDOWS) | 338 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |