Getting rid of OS::StrDup and OS::StrNDup which were sometimes misused.
Review URL: http://codereview.chromium.org/42329 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1534 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
a41b28bb03
commit
74ebdf896c
@ -199,28 +199,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
char *OS::StrDup(const char* str) {
|
||||
return strdup(str);
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrNDup(const char* str, size_t n) {
|
||||
// Stupid implementation of strndup since freebsd isn't born with
|
||||
// one.
|
||||
size_t len = strlen(str);
|
||||
if (len <= n) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
double OS::nan_value() {
|
||||
return NAN;
|
||||
}
|
||||
|
@ -196,16 +196,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrDup(const char* str) {
|
||||
return strdup(str);
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrNDup(const char* str, size_t n) {
|
||||
return strndup(str, n);
|
||||
}
|
||||
|
||||
|
||||
double OS::nan_value() {
|
||||
return NAN;
|
||||
}
|
||||
|
@ -202,28 +202,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrDup(const char* str) {
|
||||
return strdup(str);
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrNDup(const char* str, size_t n) {
|
||||
// Stupid implementation of strndup since macos isn't born with
|
||||
// one.
|
||||
size_t len = strlen(str);
|
||||
if (len <= n) {
|
||||
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
|
||||
|
@ -745,28 +745,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrDup(const char* str) {
|
||||
return _strdup(str);
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrNDup(const char* str, size_t n) {
|
||||
// Stupid implementation of strndup since windows isn't born with
|
||||
// one.
|
||||
size_t len = strlen(str);
|
||||
if (len <= n) {
|
||||
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
|
||||
|
@ -228,8 +228,6 @@ class OS {
|
||||
|
||||
static char* StrChr(char* str, int c);
|
||||
static void StrNCpy(Vector<char> dest, const char* src, size_t n);
|
||||
static char* StrDup(const char* str);
|
||||
static char* StrNDup(const char* str, size_t n);
|
||||
|
||||
// Support for profiler. Can do nothing, in which case ticks
|
||||
// occuring in shared libraries will not be properly accounted
|
||||
|
@ -44,9 +44,9 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
|
||||
basename = strrchr(const_cast<char *>(file), '\\');
|
||||
}
|
||||
if (!basename) {
|
||||
basename = v8::internal::OS::StrDup(file);
|
||||
basename = v8::internal::StrDup(file);
|
||||
} else {
|
||||
basename = v8::internal::OS::StrDup(basename + 1);
|
||||
basename = v8::internal::StrDup(basename + 1);
|
||||
}
|
||||
// Drop the extension, if there is one.
|
||||
char *extension = strrchr(basename, '.');
|
||||
@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
|
||||
print_run_count = false;
|
||||
|
||||
} else {
|
||||
char* arg_copy = v8::internal::OS::StrDup(arg);
|
||||
char* arg_copy = v8::internal::StrDup(arg);
|
||||
char* testname = strchr(arg_copy, '/');
|
||||
if (testname) {
|
||||
// Split the string in two by nulling the slash and then run
|
||||
@ -115,7 +115,7 @@ int main(int argc, char* argv[]) {
|
||||
test = test->prev();
|
||||
}
|
||||
}
|
||||
free(arg_copy);
|
||||
v8::internal::DeleteArray<char>(arg_copy);
|
||||
}
|
||||
}
|
||||
if (print_run_count && tests_run != 1)
|
||||
|
Loading…
Reference in New Issue
Block a user