| 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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 | 750 |
| 751 char* OS::StrChr(char* str, int c) { | 751 char* OS::StrChr(char* str, int c) { |
| 752 return const_cast<char*>(strchr(str, c)); | 752 return const_cast<char*>(strchr(str, c)); |
| 753 } | 753 } |
| 754 | 754 |
| 755 | 755 |
| 756 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 756 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| 757 // Use _TRUNCATE or strncpy_s crashes (by design) if buffer is too small. |
| 758 size_t buffer_size = static_cast<size_t>(dest.length()); |
| 759 if (n + 1 > buffer_size) // count for trailing '\0' |
| 760 n = _TRUNCATE; |
| 757 int result = strncpy_s(dest.start(), dest.length(), src, n); | 761 int result = strncpy_s(dest.start(), dest.length(), src, n); |
| 758 USE(result); | 762 USE(result); |
| 759 ASSERT(result == 0); | 763 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE)); |
| 760 } | 764 } |
| 761 | 765 |
| 762 | 766 |
| 763 // We keep the lowest and highest addresses mapped as a quick way of | 767 // We keep the lowest and highest addresses mapped as a quick way of |
| 764 // determining that pointers are outside the heap (used mostly in assertions | 768 // determining that pointers are outside the heap (used mostly in assertions |
| 765 // and verification). The estimate is conservative, ie, not all addresses in | 769 // and verification). The estimate is conservative, ie, not all addresses in |
| 766 // 'allocated' space are actually allocated to our heap. The range is | 770 // 'allocated' space are actually allocated to our heap. The range is |
| 767 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 771 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
| 768 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 772 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
| 769 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 773 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 | 2029 |
| 2026 void Sampler::Stop() { | 2030 void Sampler::Stop() { |
| 2027 ASSERT(IsActive()); | 2031 ASSERT(IsActive()); |
| 2028 SamplerThread::RemoveActiveSampler(this); | 2032 SamplerThread::RemoveActiveSampler(this); |
| 2029 SetActive(false); | 2033 SetActive(false); |
| 2030 } | 2034 } |
| 2031 | 2035 |
| 2032 #endif // ENABLE_LOGGING_AND_PROFILING | 2036 #endif // ENABLE_LOGGING_AND_PROFILING |
| 2033 | 2037 |
| 2034 } } // namespace v8::internal | 2038 } } // namespace v8::internal |
| OLD | NEW |