diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_main.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_main.cpp index 4b14b9d05..cc4c75baa 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_main.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_main.cpp @@ -38,23 +38,20 @@ void BpcMitmMain(void *arg) { BpcRebootManager::Initialize(); /* Create server manager */ - auto server_manager = new WaitableManager(2); + static auto s_server_manager = WaitableManager(2); /* Create bpc mitm. */ const char *service_name = "bpc"; if (GetRuntimeFirmwareVersion() < FirmwareVersion_200) { service_name = "bpc:c"; } - AddMitmServerToManager(server_manager, service_name, 13); + AddMitmServerToManager(&s_server_manager, service_name, 13); /* Extension: Allow for reboot-to-error. */ /* Must be managed port in order for sm to be able to access. */ - server_manager->AddWaitable(new ManagedPortServer("bpc:ams", 1)); + s_server_manager.AddWaitable(new ManagedPortServer("bpc:ams", 1)); /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; - + s_server_manager.Process(); } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_main.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_main.cpp index d5d5eadb9..8141ac31c 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_main.cpp @@ -37,14 +37,12 @@ using FsMitmManager = WaitableManager; void FsMitmMain(void *arg) { /* Create server manager. */ - auto server_manager = new FsMitmManager(5); + static auto s_server_manager = FsMitmManager(5); /* Create fsp-srv mitm. */ - AddMitmServerToManager(server_manager, "fsp-srv", 61); + AddMitmServerToManager(&s_server_manager, "fsp-srv", 61); /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; + s_server_manager.Process(); } diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_main.cpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_main.cpp index 136665673..637a5620d 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_main.cpp @@ -41,19 +41,16 @@ void NsMitmMain(void *arg) { nsExit(); /* Create server manager */ - auto server_manager = new WaitableManager(1); + static auto s_server_manager = WaitableManager(1); /* Create ns mitm. */ if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) { - AddMitmServerToManager(server_manager, "ns:am", 5); + AddMitmServerToManager(&s_server_manager, "ns:am", 5); } else { - AddMitmServerToManager(server_manager, "ns:web", 5); + AddMitmServerToManager(&s_server_manager, "ns:web", 5); } /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; - + s_server_manager.Process(); } diff --git a/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp b/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp index f3e80a446..1832aefd2 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp @@ -48,18 +48,15 @@ void SetMitmMain(void *arg) { VersionManager::Initialize(); /* Create server manager */ - auto server_manager = new SetMitmManager(4); + static auto s_server_manager = SetMitmManager(4); /* Create set:sys mitm. */ - AddMitmServerToManager(server_manager, "set:sys", 60); + AddMitmServerToManager(&s_server_manager, "set:sys", 60); /* Create set mitm. */ - AddMitmServerToManager(server_manager, "set", 60); + AddMitmServerToManager(&s_server_manager, "set", 60); /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; - + s_server_manager.Process(); } diff --git a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp index e569f4ace..87d0a69ee 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp @@ -987,8 +987,8 @@ void DmntCheatManager::OnNewApplicationLaunch() { } void DmntCheatManager::DetectThread(void *arg) { - auto waiter = new WaitableManager(1); - waiter->AddWaitable(LoadReadOnlySystemEvent(PrepareDebugNextApplication(), [](u64 timeout) { + static auto s_waiter = WaitableManager(1); + s_waiter.AddWaitable(LoadReadOnlySystemEvent(PrepareDebugNextApplication(), [](u64 timeout) { /* Process stuff for new application. */ DmntCheatManager::OnNewApplicationLaunch(); @@ -998,8 +998,7 @@ void DmntCheatManager::DetectThread(void *arg) { return ResultSuccess; }, true)); - waiter->Process(); - delete waiter; + s_waiter.Process(); } void DmntCheatManager::VmThread(void *arg) { @@ -1092,16 +1091,10 @@ void DmntCheatManager::InitializeCheatManager() { DmntCheatDebugEventsManager::Initialize(); /* Spawn application detection thread, spawn cheat vm thread. */ - if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39))) { - std::abort(); - } - - if (R_FAILED(g_vm_thread.Initialize(&DmntCheatManager::VmThread, nullptr, 0x4000, 48))) { - std::abort(); - } + R_ASSERT(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39)); + R_ASSERT(g_vm_thread.Initialize(&DmntCheatManager::VmThread, nullptr, 0x4000, 48)); /* Start threads. */ - if (R_FAILED(g_detect_thread.Start()) || R_FAILED(g_vm_thread.Start())) { - std::abort(); - } + R_ASSERT(g_detect_thread.Start()); + R_ASSERT(g_vm_thread.Start()); } diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index 2a9fa663d..583c30ae6 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -106,7 +106,7 @@ int main(int argc, char **argv) DmntCheatManager::InitializeCheatManager(); /* Nintendo uses four threads. Add a fifth for our cheat service. */ - auto server_manager = new WaitableManager(5); + static auto s_server_manager = WaitableManager(5); /* Create services. */ @@ -114,12 +114,10 @@ int main(int argc, char **argv) /* server_manager->AddWaitable(new ServiceServer("dmnt:-", 4)); */ - server_manager->AddWaitable(new ServiceServer("dmnt:cht", 1)); + s_server_manager.AddWaitable(new ServiceServer("dmnt:cht", 1)); /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; + s_server_manager.Process(); return 0; } diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 39bf8a86e..6da20c672 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -135,17 +135,15 @@ int main(int argc, char **argv) CheckRepairStatus(); /* TODO: What's a good timeout value to use here? */ - auto server_manager = new WaitableManager(1); + static auto s_server_manager = WaitableManager(1); /* Create services. */ - server_manager->AddWaitable(new ServiceServer("fatal:p", 4)); - server_manager->AddWaitable(new ServiceServer("fatal:u", 4)); - server_manager->AddWaitable(GetFatalSettingsEvent()); + s_server_manager.AddWaitable(new ServiceServer("fatal:p", 4)); + s_server_manager.AddWaitable(new ServiceServer("fatal:u", 4)); + s_server_manager.AddWaitable(GetFatalSettingsEvent()); /* Loop forever, servicing our services. */ - server_manager->Process(); - - delete server_manager; + s_server_manager.Process(); return 0; } diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index 59b49c0e0..4ccee4257 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit 59b49c0e0c64f896ce36180bb7d00f54f70300e9 +Subproject commit 4ccee4257763373c8e8dd5453246a592482f9a86 diff --git a/stratosphere/pm/source/pm_process_track.cpp b/stratosphere/pm/source/pm_process_track.cpp index b922c08be..797b4371c 100644 --- a/stratosphere/pm/source/pm_process_track.cpp +++ b/stratosphere/pm/source/pm_process_track.cpp @@ -21,11 +21,9 @@ void ProcessTracking::MainLoop(void *arg) { /* Make a new waitable manager. */ - auto process_waiter = new WaitableManager(1); - process_waiter->AddWaitable(Registration::GetProcessLaunchStartEvent()); + static auto s_process_waiter = WaitableManager(1); + s_process_waiter.AddWaitable(Registration::GetProcessLaunchStartEvent()); /* Service processes. */ - process_waiter->Process(); - - delete process_waiter; + s_process_waiter.Process(); } \ No newline at end of file diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index 012118c1d..0c5e1aa1f 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -83,30 +83,29 @@ int main(int argc, char **argv) consoleDebugInit(debugDevice_SVC); /* TODO: What's a good timeout value to use here? */ - auto server_manager = new WaitableManager(1); + static auto s_server_manager = WaitableManager(1); /* Create sm:, (and thus allow things to register to it). */ - server_manager->AddWaitable(new ManagedPortServer("sm:", 0x40)); + s_server_manager.AddWaitable(new ManagedPortServer("sm:", 0x40)); /* Create sm:m manually. */ Handle smm_h; R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h)); - server_manager->AddWaitable(new ExistingPortServer(smm_h, 1)); + s_server_manager.AddWaitable(new ExistingPortServer(smm_h, 1)); /*===== ATMOSPHERE EXTENSION =====*/ /* Create sm:dmnt manually. */ Handle smdmnt_h; R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h)); - server_manager->AddWaitable(new ExistingPortServer(smm_h, 1));; + s_server_manager.AddWaitable(new ExistingPortServer(smm_h, 1));; /*================================*/ /* Loop forever, servicing our services. */ - server_manager->Process(); + s_server_manager.Process(); /* Cleanup. */ - delete server_manager; return 0; }