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

Side by Side Diff: runtime/bin/dartutils.cc

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/dartutils.h ('k') | runtime/bin/directory.h » ('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 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 ASSERT(suffix != NULL); 623 ASSERT(suffix != NULL);
624 Dart_Handle res = Dart_NewStringFromCString(suffix); 624 Dart_Handle res = Dart_NewStringFromCString(suffix);
625 if (Dart_IsError(res)) { 625 if (Dart_IsError(res)) {
626 Dart_PropagateError(res); 626 Dart_PropagateError(res);
627 } 627 }
628 Dart_SetReturnValue(args, res); 628 Dart_SetReturnValue(args, res);
629 } 629 }
630 630
631 631
632 void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) { 632 void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) {
633 char* current = Directory::Current(); 633 const char* current = Directory::Current();
634 if (current != NULL) { 634 if (current != NULL) {
635 Dart_SetReturnValue(args, DartUtils::NewString(current)); 635 Dart_SetReturnValue(args, DartUtils::NewString(current));
636 free(current);
637 } else { 636 } else {
638 Dart_Handle err = DartUtils::NewError("Failed to get current directory."); 637 Dart_Handle err = DartUtils::NewError("Failed to get current directory.");
639 Dart_PropagateError(err); 638 Dart_PropagateError(err);
640 } 639 }
641 } 640 }
642 641
643 642
644 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib, 643 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
645 Dart_Handle internal_lib, 644 Dart_Handle internal_lib,
646 bool is_service_isolate, 645 bool is_service_isolate,
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 return Dart_NewApiError(buffer); 944 return Dart_NewApiError(buffer);
946 } 945 }
947 946
948 947
949 Dart_Handle DartUtils::NewInternalError(const char* message) { 948 Dart_Handle DartUtils::NewInternalError(const char* message) {
950 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message); 949 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message);
951 } 950 }
952 951
953 952
954 bool DartUtils::SetOriginalWorkingDirectory() { 953 bool DartUtils::SetOriginalWorkingDirectory() {
955 original_working_directory = Directory::Current(); 954 original_working_directory = Directory::CurrentNoScope();
956 return original_working_directory != NULL; 955 return original_working_directory != NULL;
957 } 956 }
958 957
959 958
960 // Statically allocated Dart_CObject instances for immutable 959 // Statically allocated Dart_CObject instances for immutable
961 // objects. As these will be used by different threads the use of 960 // objects. As these will be used by different threads the use of
962 // these depends on the fact that the marking internally in the 961 // these depends on the fact that the marking internally in the
963 // Dart_CObject structure is not marking simple value objects. 962 // Dart_CObject structure is not marking simple value objects.
964 Dart_CObject CObject::api_null_ = { Dart_CObject_kNull , { 0 } }; 963 Dart_CObject CObject::api_null_ = { Dart_CObject_kNull , { 0 } };
965 Dart_CObject CObject::api_true_ = { Dart_CObject_kBool , { true } }; 964 Dart_CObject CObject::api_true_ = { Dart_CObject_kBool , { true } };
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 new CObjectString(CObject::NewString(os_error->message())); 1260 new CObjectString(CObject::NewString(os_error->message()));
1262 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1261 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1263 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1262 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1264 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1263 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1265 result->SetAt(2, error_message); 1264 result->SetAt(2, error_message);
1266 return result; 1265 return result;
1267 } 1266 }
1268 1267
1269 } // namespace bin 1268 } // namespace bin
1270 } // namespace dart 1269 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/directory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698