Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: src/platform-win32.cc

Issue 42329: Getting rid of OS::StrDup and OS::StrNDup which were sometimes misused. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-macos.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 738 }
739 739
740 740
741 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 741 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
742 int result = strncpy_s(dest.start(), dest.length(), src, n); 742 int result = strncpy_s(dest.start(), dest.length(), src, n);
743 USE(result); 743 USE(result);
744 ASSERT(result == 0); 744 ASSERT(result == 0);
745 } 745 }
746 746
747 747
748 char* OS::StrDup(const char* str) {
749 return _strdup(str);
750 }
751
752
753 char* OS::StrNDup(const char* str, size_t n) {
754 // Stupid implementation of strndup since windows isn't born with
755 // one.
756 size_t len = strlen(str);
757 if (len <= n) {
758 return StrDup(str);
759 }
760 char* result = new char[n+1];
761 size_t i;
762 for (i = 0; i <= n; i++) {
763 result[i] = str[i];
764 }
765 result[i] = '\0';
766 return result;
767 }
768
769
770 // We keep the lowest and highest addresses mapped as a quick way of 748 // We keep the lowest and highest addresses mapped as a quick way of
771 // determining that pointers are outside the heap (used mostly in assertions 749 // determining that pointers are outside the heap (used mostly in assertions
772 // and verification). The estimate is conservative, ie, not all addresses in 750 // and verification). The estimate is conservative, ie, not all addresses in
773 // 'allocated' space are actually allocated to our heap. The range is 751 // 'allocated' space are actually allocated to our heap. The range is
774 // [lowest, highest), inclusive on the low and and exclusive on the high end. 752 // [lowest, highest), inclusive on the low and and exclusive on the high end.
775 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); 753 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
776 static void* highest_ever_allocated = reinterpret_cast<void*>(0); 754 static void* highest_ever_allocated = reinterpret_cast<void*>(0);
777 755
778 756
779 static void UpdateAllocatedSpaceLimits(void* address, int size) { 757 static void UpdateAllocatedSpaceLimits(void* address, int size) {
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 1801
1824 // Release the thread handles 1802 // Release the thread handles
1825 CloseHandle(data_->sampler_thread_); 1803 CloseHandle(data_->sampler_thread_);
1826 CloseHandle(data_->profiled_thread_); 1804 CloseHandle(data_->profiled_thread_);
1827 } 1805 }
1828 1806
1829 1807
1830 #endif // ENABLE_LOGGING_AND_PROFILING 1808 #endif // ENABLE_LOGGING_AND_PROFILING
1831 1809
1832 } } // namespace v8::internal 1810 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-macos.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698