Commit 74ebdf89 authored by olehougaard's avatar olehougaard

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
parent a41b28bb
...@@ -199,28 +199,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { ...@@ -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() { double OS::nan_value() {
return NAN; return NAN;
} }
......
...@@ -196,16 +196,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { ...@@ -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() { double OS::nan_value() {
return NAN; return NAN;
} }
......
...@@ -202,28 +202,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { ...@@ -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 // We keep the lowest and highest addresses mapped as a quick way of
// determining that pointers are outside the heap (used mostly in assertions // determining that pointers are outside the heap (used mostly in assertions
// and verification). The estimate is conservative, ie, not all addresses in // 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) { ...@@ -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 // We keep the lowest and highest addresses mapped as a quick way of
// determining that pointers are outside the heap (used mostly in assertions // determining that pointers are outside the heap (used mostly in assertions
// and verification). The estimate is conservative, ie, not all addresses in // and verification). The estimate is conservative, ie, not all addresses in
......
...@@ -228,8 +228,6 @@ class OS { ...@@ -228,8 +228,6 @@ class OS {
static char* StrChr(char* str, int c); static char* StrChr(char* str, int c);
static void StrNCpy(Vector<char> dest, const char* src, size_t n); 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 // Support for profiler. Can do nothing, in which case ticks
// occuring in shared libraries will not be properly accounted // occuring in shared libraries will not be properly accounted
......
...@@ -44,9 +44,9 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name, ...@@ -44,9 +44,9 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
basename = strrchr(const_cast<char *>(file), '\\'); basename = strrchr(const_cast<char *>(file), '\\');
} }
if (!basename) { if (!basename) {
basename = v8::internal::OS::StrDup(file); basename = v8::internal::StrDup(file);
} else { } else {
basename = v8::internal::OS::StrDup(basename + 1); basename = v8::internal::StrDup(basename + 1);
} }
// Drop the extension, if there is one. // Drop the extension, if there is one.
char *extension = strrchr(basename, '.'); char *extension = strrchr(basename, '.');
...@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) { ...@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
print_run_count = false; print_run_count = false;
} else { } else {
char* arg_copy = v8::internal::OS::StrDup(arg); char* arg_copy = v8::internal::StrDup(arg);
char* testname = strchr(arg_copy, '/'); char* testname = strchr(arg_copy, '/');
if (testname) { if (testname) {
// Split the string in two by nulling the slash and then run // Split the string in two by nulling the slash and then run
...@@ -115,7 +115,7 @@ int main(int argc, char* argv[]) { ...@@ -115,7 +115,7 @@ int main(int argc, char* argv[]) {
test = test->prev(); test = test->prev();
} }
} }
free(arg_copy); v8::internal::DeleteArray<char>(arg_copy);
} }
} }
if (print_run_count && tests_run != 1) if (print_run_count && tests_run != 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment