| 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), | |
| 21 kernel_program(NULL), | 20 kernel_program(NULL), |
| 22 builtin_lib_(NULL), | 21 builtin_lib_(NULL), |
| 23 loader_(NULL), | 22 loader_(NULL), |
| 24 app_snapshot_(app_snapshot), | 23 app_snapshot_(app_snapshot), |
| 25 dependencies_(NULL) { | 24 dependencies_(NULL) { |
| 26 if (package_root != NULL) { | 25 if (package_root != NULL) { |
| 27 ASSERT(packages_file == NULL); | 26 ASSERT(packages_file == NULL); |
| 28 this->package_root = strdup(package_root); | 27 this->package_root = strdup(package_root); |
| 29 } else if (packages_file != NULL) { | 28 } else if (packages_file != NULL) { |
| 30 this->packages_file = strdup(packages_file); | 29 this->packages_file = strdup(packages_file); |
| 31 } | 30 } |
| 32 } | 31 } |
| 33 | 32 |
| 34 void IsolateData::OnIsolateShutdown() { | 33 void IsolateData::OnIsolateShutdown() { |
| 35 if (builtin_lib_ != NULL) { | 34 if (builtin_lib_ != NULL) { |
| 36 Dart_DeletePersistentHandle(builtin_lib_); | 35 Dart_DeletePersistentHandle(builtin_lib_); |
| 37 builtin_lib_ = NULL; | 36 builtin_lib_ = NULL; |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 IsolateData::~IsolateData() { | 40 IsolateData::~IsolateData() { |
| 42 free(script_url); | 41 free(script_url); |
| 43 script_url = NULL; | 42 script_url = NULL; |
| 44 free(package_root); | 43 free(package_root); |
| 45 package_root = NULL; | 44 package_root = NULL; |
| 46 free(packages_file); | 45 free(packages_file); |
| 47 packages_file = NULL; | 46 packages_file = NULL; |
| 48 free(udp_receive_buffer); | |
| 49 udp_receive_buffer = NULL; | |
| 50 if (kernel_program != NULL) { | 47 if (kernel_program != NULL) { |
| 51 delete reinterpret_cast<kernel::Program*>(kernel_program); | 48 delete reinterpret_cast<kernel::Program*>(kernel_program); |
| 52 kernel_program = NULL; | 49 kernel_program = NULL; |
| 53 } | 50 } |
| 54 delete app_snapshot_; | 51 delete app_snapshot_; |
| 55 app_snapshot_ = NULL; | 52 app_snapshot_ = NULL; |
| 56 } | 53 } |
| 57 | 54 |
| 58 } // namespace bin | 55 } // namespace bin |
| 59 } // namespace dart | 56 } // namespace dart |
| OLD | NEW |