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); |