summaryrefslogtreecommitdiff
path: root/dexlayout/dexlayout_main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dexlayout/dexlayout_main.cc')
-rw-r--r--dexlayout/dexlayout_main.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index 38faf9688b..33d62decca 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -67,7 +67,7 @@ static void Usage(void) {
*/
int DexlayoutDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
Options options;
@@ -170,14 +170,14 @@ int DexlayoutDriver(int argc, char** argv) {
}
// Open profile file.
- ProfileCompilationInfo* profile_info = nullptr;
+ std::unique_ptr<ProfileCompilationInfo> profile_info;
if (options.profile_file_name_) {
int profile_fd = open(options.profile_file_name_, O_RDONLY);
if (profile_fd < 0) {
fprintf(stderr, "Can't open %s\n", options.profile_file_name_);
return 1;
}
- profile_info = new ProfileCompilationInfo();
+ profile_info.reset(new ProfileCompilationInfo());
if (!profile_info->Load(profile_fd)) {
fprintf(stderr, "Can't read profile info from %s\n", options.profile_file_name_);
return 1;
@@ -185,13 +185,19 @@ int DexlayoutDriver(int argc, char** argv) {
}
// Create DexLayout instance.
- DexLayout dex_layout(options, profile_info, out_file);
+ DexLayout dex_layout(options, profile_info.get(), out_file);
// Process all files supplied on command line.
int result = 0;
while (optind < argc) {
result |= dex_layout.ProcessFile(argv[optind++]);
} // while
+
+ if (options.output_file_name_) {
+ CHECK(out_file != nullptr && out_file != stdout);
+ fclose(out_file);
+ }
+
return result != 0;
}