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

Unified Diff: runtime/bin/dartutils.h

Issue 1781883002: Fixes some memory leaks in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix tests on Windows Created 4 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 | « runtime/bin/crypto_win.cc ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.h
diff --git a/runtime/bin/dartutils.h b/runtime/bin/dartutils.h
index 1d18b5f96e58729e7c48fd7d85dfa64065cfae06..adc7d3f18fe6bffc75a7cf5dfd7dfac76412b6b2 100644
--- a/runtime/bin/dartutils.h
+++ b/runtime/bin/dartutils.h
@@ -165,6 +165,23 @@ class DartUtils {
strlen(str));
}
+ // Allocate length bytes for a C string with Dart_ScopeAllocate.
+ static char* ScopedCString(intptr_t length) {
+ char* result = NULL;
+ result = reinterpret_cast<char*>(
+ Dart_ScopeAllocate(length * sizeof(*result)));
+ return result;
+ }
+
+ // Copy str into a buffer allocated with Dart_ScopeAllocate.
+ static char* ScopedCopyCString(const char* str) {
+ size_t str_len = strlen(str);
+ char* result = ScopedCString(str_len + 1);
+ memmove(result, str, str_len);
+ result[str_len] = '\0';
+ return result;
+ }
+
// Create a new Dart InternalError object with the provided message.
static Dart_Handle NewError(const char* format, ...);
static Dart_Handle NewInternalError(const char* message);
« no previous file with comments | « runtime/bin/crypto_win.cc ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698