Chromium Code Reviews| Index: src/platform-macos.cc |
| diff --git a/src/platform-macos.cc b/src/platform-macos.cc |
| index f08d64d0c961c53d51ad125314c8d31129d0ce6b..80308a67736b30341f6136f2d7e8fee04a9c4020 100644 |
| --- a/src/platform-macos.cc |
| +++ b/src/platform-macos.cc |
| @@ -190,11 +190,26 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| } |
| -char *OS::StrDup(const char* str) { |
| +char* OS::StrDup(const char* str) { |
| return strdup(str); |
| } |
| +char* OS::StrNDup(const char* str, size_t n) { |
| + // Stupid implementation of strndup since mac isn't born with |
| + // one. |
| + size_t len = strlen(str); |
| + if (len < n) |
|
Erik Corry
2008/12/03 13:43:22
Might as well use StrDup for the case where len ==
|
| + return StrDup(str); |
| + char* result = new char[n+1]; |
| + size_t i; |
| + for (i = 0; i <= n; i++) |
| + result[i] = str[i]; |
| + result[i] = '\0'; |
| + return result; |
| +} |
| + |
| + |
| // We keep the lowest and highest addresses mapped as a quick way of |
| // determining that pointers are outside the heap (used mostly in assertions |
| // and verification). The estimate is conservative, ie, not all addresses in |