| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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/isolate_data.h" | 5 #include "bin/isolate_data.h" |
| 6 #include "bin/snapshot_utils.h" | 6 #include "bin/snapshot_utils.h" |
| 7 | 7 |
| 8 #include "vm/kernel.h" | 8 #include "vm/kernel.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 namespace bin { | 11 namespace bin { |
| 12 | 12 |
| 13 IsolateData::IsolateData(const char* url, | 13 IsolateData::IsolateData(const char* url, |
| 14 const char* package_root, | 14 const char* package_root, |
| 15 const char* packages_file, | 15 const char* packages_file, |
| 16 AppSnapshot* app_snapshot) | 16 AppSnapshot* app_snapshot) |
| 17 : script_url((url != NULL) ? strdup(url) : NULL), | 17 : script_url((url != NULL) ? strdup(url) : NULL), |
| 18 package_root(NULL), | 18 package_root(NULL), |
| 19 packages_file(NULL), | 19 packages_file(NULL), |
| 20 udp_receive_buffer(NULL), |
| 20 kernel_program(NULL), | 21 kernel_program(NULL), |
| 21 builtin_lib_(NULL), | 22 builtin_lib_(NULL), |
| 22 loader_(NULL), | 23 loader_(NULL), |
| 23 app_snapshot_(app_snapshot), | 24 app_snapshot_(app_snapshot), |
| 24 dependencies_(NULL) { | 25 dependencies_(NULL) { |
| 25 if (package_root != NULL) { | 26 if (package_root != NULL) { |
| 26 ASSERT(packages_file == NULL); | 27 ASSERT(packages_file == NULL); |
| 27 this->package_root = strdup(package_root); | 28 this->package_root = strdup(package_root); |
| 28 } else if (packages_file != NULL) { | 29 } else if (packages_file != NULL) { |
| 29 this->packages_file = strdup(packages_file); | 30 this->packages_file = strdup(packages_file); |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 | 33 |
| 33 void IsolateData::OnIsolateShutdown() { | 34 void IsolateData::OnIsolateShutdown() { |
| 34 if (builtin_lib_ != NULL) { | 35 if (builtin_lib_ != NULL) { |
| 35 Dart_DeletePersistentHandle(builtin_lib_); | 36 Dart_DeletePersistentHandle(builtin_lib_); |
| 36 builtin_lib_ = NULL; | 37 builtin_lib_ = NULL; |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 IsolateData::~IsolateData() { | 41 IsolateData::~IsolateData() { |
| 41 free(script_url); | 42 free(script_url); |
| 42 script_url = NULL; | 43 script_url = NULL; |
| 43 free(package_root); | 44 free(package_root); |
| 44 package_root = NULL; | 45 package_root = NULL; |
| 45 free(packages_file); | 46 free(packages_file); |
| 46 packages_file = NULL; | 47 packages_file = NULL; |
| 48 free(udp_receive_buffer); |
| 49 udp_receive_buffer = NULL; |
| 47 if (kernel_program != NULL) { | 50 if (kernel_program != NULL) { |
| 48 delete reinterpret_cast<kernel::Program*>(kernel_program); | 51 delete reinterpret_cast<kernel::Program*>(kernel_program); |
| 49 kernel_program = NULL; | 52 kernel_program = NULL; |
| 50 } | 53 } |
| 51 delete app_snapshot_; | 54 delete app_snapshot_; |
| 52 app_snapshot_ = NULL; | 55 app_snapshot_ = NULL; |
| 53 } | 56 } |
| 54 | 57 |
| 55 } // namespace bin | 58 } // namespace bin |
| 56 } // namespace dart | 59 } // namespace dart |
| OLD | NEW |