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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/crypto_win.cc ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_DARTUTILS_H_ 5 #ifndef BIN_DARTUTILS_H_
6 #define BIN_DARTUTILS_H_ 6 #define BIN_DARTUTILS_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const char* message, 158 const char* message,
159 Dart_Handle os_error); 159 Dart_Handle os_error);
160 160
161 // Create a new Dart String object from a C String. 161 // Create a new Dart String object from a C String.
162 static Dart_Handle NewString(const char* str) { 162 static Dart_Handle NewString(const char* str) {
163 ASSERT(str != NULL); 163 ASSERT(str != NULL);
164 return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), 164 return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str),
165 strlen(str)); 165 strlen(str));
166 } 166 }
167 167
168 // Allocate length bytes for a C string with Dart_ScopeAllocate.
169 static char* ScopedCString(intptr_t length) {
170 char* result = NULL;
171 result = reinterpret_cast<char*>(
172 Dart_ScopeAllocate(length * sizeof(*result)));
173 return result;
174 }
175
176 // Copy str into a buffer allocated with Dart_ScopeAllocate.
177 static char* ScopedCopyCString(const char* str) {
178 size_t str_len = strlen(str);
179 char* result = ScopedCString(str_len + 1);
180 memmove(result, str, str_len);
181 result[str_len] = '\0';
182 return result;
183 }
184
168 // Create a new Dart InternalError object with the provided message. 185 // Create a new Dart InternalError object with the provided message.
169 static Dart_Handle NewError(const char* format, ...); 186 static Dart_Handle NewError(const char* format, ...);
170 static Dart_Handle NewInternalError(const char* message); 187 static Dart_Handle NewInternalError(const char* message);
171 188
172 static Dart_Handle BuiltinLib() { 189 static Dart_Handle BuiltinLib() {
173 IsolateData* isolate_data = 190 IsolateData* isolate_data =
174 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); 191 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
175 return isolate_data->builtin_lib(); 192 return isolate_data->builtin_lib();
176 } 193 }
177 194
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 601
585 ~ScopedBlockingCall() { 602 ~ScopedBlockingCall() {
586 Dart_ThreadEnableProfiling(); 603 Dart_ThreadEnableProfiling();
587 } 604 }
588 }; 605 };
589 606
590 } // namespace bin 607 } // namespace bin
591 } // namespace dart 608 } // namespace dart
592 609
593 #endif // BIN_DARTUTILS_H_ 610 #endif // BIN_DARTUTILS_H_
OLDNEW
« 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