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
3// BSD-style license that can be found in the LICENSE file.
4
5#include "bin/isolate_data.h"
6#include "bin/snapshot_utils.h"
7#include "platform/growable_array.h"
8
9namespace dart {
10namespace bin {
11
12IsolateGroupData::IsolateGroupData(const char* url,
13 const char* packages_file,
14 AppSnapshot* app_snapshot,
15 bool isolate_run_app_snapshot)
16 : script_url((url != NULL) ? Utils::StrDup(url) : NULL),
17 app_snapshot_(app_snapshot),
18 resolved_packages_config_(NULL),
19 kernel_buffer_(NULL),
20 kernel_buffer_size_(0),
21 isolate_run_app_snapshot_(isolate_run_app_snapshot) {
22 if (packages_file != NULL) {
23 packages_file_ = Utils::StrDup(packages_file);
24 }
25}
26
27IsolateGroupData::~IsolateGroupData() {
28 for (intptr_t i = 0; i < loading_units_.length(); i++) {
29 delete loading_units_[i];
30 }
31 free(script_url);
32 script_url = nullptr;
33 free(packages_file_);
34 packages_file_ = nullptr;
35 free(resolved_packages_config_);
36 resolved_packages_config_ = nullptr;
37 kernel_buffer_ = nullptr;
38 kernel_buffer_size_ = 0;
39}
40
41IsolateData::IsolateData(IsolateGroupData* isolate_group_data)
42 : isolate_group_data_(isolate_group_data),
43 loader_(nullptr),
44 packages_file_(nullptr) {
45 if (isolate_group_data->packages_file_ != nullptr) {
46 packages_file_ = Utils::StrDup(isolate_group_data->packages_file_);
47 }
48}
49
50IsolateData::~IsolateData() {
51 free(packages_file_);
52 packages_file_ = nullptr;
53}
54
55} // namespace bin
56} // namespace dart
57