OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 int OS::SNPrintF(Vector<char> str, const char* format, ...) { | 661 int OS::SNPrintF(Vector<char> str, const char* format, ...) { |
662 va_list args; | 662 va_list args; |
663 va_start(args, format); | 663 va_start(args, format); |
664 int result = VSNPrintF(str, format, args); | 664 int result = VSNPrintF(str, format, args); |
665 va_end(args); | 665 va_end(args); |
666 return result; | 666 return result; |
667 } | 667 } |
668 | 668 |
669 | 669 |
670 int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) { | 670 int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) { |
671 int n = _vsnprintf_s(str.start(), str.length(), str.length(), format, args); | 671 int n = _vsnprintf_s(str.start(), str.length(), _TRUNCATE, format, args); |
672 // Make sure to zero-terminate the string if the output was | 672 // Make sure to zero-terminate the string if the output was |
673 // truncated or if there was an error. | 673 // truncated or if there was an error. |
674 if (n < 0 || n >= str.length()) { | 674 if (n < 0 || n >= str.length()) { |
675 str[str.length() - 1] = '\0'; | 675 str[str.length() - 1] = '\0'; |
676 return -1; | 676 return -1; |
677 } else { | 677 } else { |
678 return n; | 678 return n; |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 | 682 |
683 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 683 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
684 int result = strncpy_s(dest.start(), dest.length(), src, n); | 684 int result = strncpy_s(dest.start(), dest.length(), src, n); |
685 USE(result); ASSERT(result == 0); | 685 USE(result); |
| 686 ASSERT(result == 0); |
686 } | 687 } |
687 | 688 |
688 | 689 |
689 void OS::WcsCpy(Vector<wchar_t> dest, const wchar_t* src) { | 690 void OS::WcsCpy(Vector<wchar_t> dest, const wchar_t* src) { |
690 int result = wcscpy_s(dest.start(), dest.length(), src); | 691 int result = wcscpy_s(dest.start(), dest.length(), src); |
691 USE(result); ASSERT(result == 0); | 692 USE(result); |
| 693 ASSERT(result == 0); |
692 } | 694 } |
693 | 695 |
694 | 696 |
695 char *OS::StrDup(const char* str) { | 697 char *OS::StrDup(const char* str) { |
696 return _strdup(str); | 698 return _strdup(str); |
697 } | 699 } |
698 | 700 |
699 | 701 |
700 // We keep the lowest and highest addresses mapped as a quick way of | 702 // We keep the lowest and highest addresses mapped as a quick way of |
701 // determining that pointers are outside the heap (used mostly in assertions | 703 // determining that pointers are outside the heap (used mostly in assertions |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1565 |
1564 // Release the thread handles | 1566 // Release the thread handles |
1565 CloseHandle(data_->sampler_thread_); | 1567 CloseHandle(data_->sampler_thread_); |
1566 CloseHandle(data_->profiled_thread_); | 1568 CloseHandle(data_->profiled_thread_); |
1567 } | 1569 } |
1568 | 1570 |
1569 | 1571 |
1570 #endif // ENABLE_LOGGING_AND_PROFILING | 1572 #endif // ENABLE_LOGGING_AND_PROFILING |
1571 | 1573 |
1572 } } // namespace v8::internal | 1574 } } // namespace v8::internal |
OLD | NEW |