From c950998c91030214a2269f64ced99018599eceb9 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 16 Jun 2018 18:00:40 +0200 Subject: [PATCH] Stratosphere: Use unique_ptr --- stratosphere/loader/source/ldr_main.cpp | 4 +--- stratosphere/pm/source/pm_registration.cpp | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/stratosphere/loader/source/ldr_main.cpp b/stratosphere/loader/source/ldr_main.cpp index e1633cb66..5d6f5a01c 100644 --- a/stratosphere/loader/source/ldr_main.cpp +++ b/stratosphere/loader/source/ldr_main.cpp @@ -93,7 +93,7 @@ int main(int argc, char **argv) consoleDebugInit(debugDevice_SVC); /* TODO: What's a good timeout value to use here? */ - WaitableManager *server_manager = new WaitableManager(U64_MAX); + auto server_manager = std::make_unique(U64_MAX); /* Add services to manager. */ server_manager->add_waitable(new ServiceServer("ldr:pm", 1)); @@ -107,8 +107,6 @@ int main(int argc, char **argv) /* Loop forever, servicing our services. */ server_manager->process(); - /* Cleanup. */ - delete server_manager; return 0; } diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index 405903515..d3c0c05b7 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -71,9 +71,9 @@ void Registration::HandleProcessLaunch() { u64 *out_pid = g_process_launch_state.out_pid; Process new_process = {0}; new_process.tid_sid = g_process_launch_state.tid_sid; - u8 *ac_buf = new u8[4 * sizeof(LoaderProgramInfo)]; - std::fill(ac_buf, ac_buf + 4 * sizeof(LoaderProgramInfo), 0xCC); - u8 *acid_sac = ac_buf, *aci0_sac = acid_sac + sizeof(LoaderProgramInfo), *fac = aci0_sac + sizeof(LoaderProgramInfo), *fah = fac + sizeof(LoaderProgramInfo); + auto ac_buf = std::vector(4 * sizeof(LoaderProgramInfo)); + std::fill(ac_buf.begin(), ac_buf.end(), 0xCC); + u8 *acid_sac = ac_buf.data(), *aci0_sac = acid_sac + sizeof(LoaderProgramInfo), *fac = aci0_sac + sizeof(LoaderProgramInfo), *fah = fac + sizeof(LoaderProgramInfo); /* Check that this is a real program. */ if (R_FAILED((rc = ldrPmGetProgramInfo(new_process.tid_sid.title_id, new_process.tid_sid.storage_id, &program_info)))) { @@ -180,7 +180,6 @@ HANDLE_PROCESS_LAUNCH_END: if (R_SUCCEEDED(rc)) { *out_pid = new_process.pid; } - delete ac_buf; g_sema_finish_launch.Signal(); }