Chromium Code Reviews| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 return n; | 183 return n; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 188 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| 189 strncpy(dest.start(), src, n); | 189 strncpy(dest.start(), src, n); |
| 190 } | 190 } |
| 191 | 191 |
| 192 | 192 |
| 193 char *OS::StrDup(const char* str) { | 193 char* OS::StrDup(const char* str) { |
| 194 return strdup(str); | 194 return strdup(str); |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 char* OS::StrNDup(const char* str, size_t n) { | |
| 199 // Stupid implementation of strndup since mac isn't born with | |
| 200 // one. | |
| 201 size_t len = strlen(str); | |
| 202 if (len < n) | |
|
Erik Corry
2008/12/03 13:43:22
Might as well use StrDup for the case where len ==
| |
| 203 return StrDup(str); | |
| 204 char* result = new char[n+1]; | |
| 205 size_t i; | |
| 206 for (i = 0; i <= n; i++) | |
| 207 result[i] = str[i]; | |
| 208 result[i] = '\0'; | |
| 209 return result; | |
| 210 } | |
| 211 | |
| 212 | |
| 198 // We keep the lowest and highest addresses mapped as a quick way of | 213 // We keep the lowest and highest addresses mapped as a quick way of |
| 199 // determining that pointers are outside the heap (used mostly in assertions | 214 // determining that pointers are outside the heap (used mostly in assertions |
| 200 // and verification). The estimate is conservative, ie, not all addresses in | 215 // and verification). The estimate is conservative, ie, not all addresses in |
| 201 // 'allocated' space are actually allocated to our heap. The range is | 216 // 'allocated' space are actually allocated to our heap. The range is |
| 202 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 217 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
| 203 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 218 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
| 204 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 219 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
| 205 | 220 |
| 206 | 221 |
| 207 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 222 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 } | 653 } |
| 639 | 654 |
| 640 // This sampler is no longer the active sampler. | 655 // This sampler is no longer the active sampler. |
| 641 active_sampler_ = NULL; | 656 active_sampler_ = NULL; |
| 642 active_ = false; | 657 active_ = false; |
| 643 } | 658 } |
| 644 | 659 |
| 645 #endif // ENABLE_LOGGING_AND_PROFILING | 660 #endif // ENABLE_LOGGING_AND_PROFILING |
| 646 | 661 |
| 647 } } // namespace v8::internal | 662 } } // namespace v8::internal |
| OLD | NEW |