Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Unified Diff: src/allocation.cc

Issue 48127: Introducing a new StrNDup function that uses new[] for when we dispose the re... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/allocation.h ('k') | src/d8-readline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/allocation.cc
===================================================================
--- src/allocation.cc (revision 1525)
+++ src/allocation.cc (working copy)
@@ -87,6 +87,16 @@
}
+char* StrNDup(const char* str, size_t n) {
+ size_t length = strlen(str);
+ if (n < length) length = n;
+ char* result = NewArray<char>(length + 1);
+ memcpy(result, str, length * kCharSize);
+ result[length] = '\0';
+ return result;
+}
+
+
int NativeAllocationChecker::allocation_disallowed_ = 0;
« no previous file with comments | « src/allocation.h ('k') | src/d8-readline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698