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

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

Issue 1892623002: Fixes leak of native File objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 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/file_win.cc ('k') | runtime/bin/io_natives.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 208
209 static void WriteSnapshotFile(const char* filename, 209 static void WriteSnapshotFile(const char* filename,
210 const uint8_t* buffer, 210 const uint8_t* buffer,
211 const intptr_t size) { 211 const intptr_t size) {
212 File* file = File::Open(filename, File::kWriteTruncate); 212 File* file = File::Open(filename, File::kWriteTruncate);
213 ASSERT(file != NULL); 213 ASSERT(file != NULL);
214 if (!file->WriteFully(buffer, size)) { 214 if (!file->WriteFully(buffer, size)) {
215 Log::PrintErr("Error: Failed to write snapshot file.\n\n"); 215 Log::PrintErr("Error: Failed to write snapshot file.\n\n");
216 } 216 }
217 delete file; 217 file->Release();
218 } 218 }
219 219
220 220
221 class UriResolverIsolateScope { 221 class UriResolverIsolateScope {
222 public: 222 public:
223 UriResolverIsolateScope() { 223 UriResolverIsolateScope() {
224 ASSERT(isolate != NULL); 224 ASSERT(isolate != NULL);
225 snapshotted_isolate_ = Dart_CurrentIsolate(); 225 snapshotted_isolate_ = Dart_CurrentIsolate();
226 Dart_ExitIsolate(); 226 Dart_ExitIsolate();
227 Dart_EnterIsolate(isolate); 227 Dart_EnterIsolate(isolate);
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 EventHandler::Stop(); 1152 EventHandler::Stop();
1153 return 0; 1153 return 0;
1154 } 1154 }
1155 1155
1156 } // namespace bin 1156 } // namespace bin
1157 } // namespace dart 1157 } // namespace dart
1158 1158
1159 int main(int argc, char** argv) { 1159 int main(int argc, char** argv) {
1160 return dart::bin::main(argc, argv); 1160 return dart::bin::main(argc, argv);
1161 } 1161 }
OLDNEW
« no previous file with comments | « runtime/bin/file_win.cc ('k') | runtime/bin/io_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698