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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 char* OS::StrChr(char* str, int c) { | 195 char* OS::StrChr(char* str, int c) { |
196 return strchr(str, c); | 196 return strchr(str, c); |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 200 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
201 strncpy(dest.start(), src, n); | 201 strncpy(dest.start(), src, n); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 char* OS::StrDup(const char* str) { | |
206 return strdup(str); | |
207 } | |
208 | |
209 | |
210 char* OS::StrNDup(const char* str, size_t n) { | |
211 // Stupid implementation of strndup since macos isn't born with | |
212 // one. | |
213 size_t len = strlen(str); | |
214 if (len <= n) { | |
215 return StrDup(str); | |
216 } | |
217 char* result = new char[n+1]; | |
218 size_t i; | |
219 for (i = 0; i <= n; i++) { | |
220 result[i] = str[i]; | |
221 } | |
222 result[i] = '\0'; | |
223 return result; | |
224 } | |
225 | |
226 | |
227 // We keep the lowest and highest addresses mapped as a quick way of | 205 // We keep the lowest and highest addresses mapped as a quick way of |
228 // determining that pointers are outside the heap (used mostly in assertions | 206 // determining that pointers are outside the heap (used mostly in assertions |
229 // and verification). The estimate is conservative, ie, not all addresses in | 207 // and verification). The estimate is conservative, ie, not all addresses in |
230 // 'allocated' space are actually allocated to our heap. The range is | 208 // 'allocated' space are actually allocated to our heap. The range is |
231 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 209 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
232 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 210 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
233 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 211 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
234 | 212 |
235 | 213 |
236 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 214 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 805 } |
828 | 806 |
829 // This sampler is no longer the active sampler. | 807 // This sampler is no longer the active sampler. |
830 active_sampler_ = NULL; | 808 active_sampler_ = NULL; |
831 active_ = false; | 809 active_ = false; |
832 } | 810 } |
833 | 811 |
834 #endif // ENABLE_LOGGING_AND_PROFILING | 812 #endif // ENABLE_LOGGING_AND_PROFILING |
835 | 813 |
836 } } // namespace v8::internal | 814 } } // namespace v8::internal |
OLD | NEW |