From 78565fabbc2ec3837163cbbec59c7cf41164b4ac Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Dec 2015 10:28:40 -0500 Subject: [PATCH] DSPCore: Make the DSP emitter global a unique_ptr --- Source/Core/Core/DSP/DSPCore.cpp | 12 ++++-------- Source/Core/Core/DSP/DSPCore.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 2c945a0dd1..3a4adb3ce5 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" @@ -26,7 +27,7 @@ DSPBreakpoints dsp_breakpoints; static DSPCoreState core_state = DSPCORE_STOP; u16 cyclesLeft = 0; bool init_hax = false; -DSPEmitter *dspjit = nullptr; +std::unique_ptr dspjit; std::unique_ptr g_dsp_cap; static Common::Event step_event; @@ -102,7 +103,6 @@ bool DSPCore_Init(const DSPInitOptions& opts) g_dsp.step_counter = 0; cyclesLeft = 0; init_hax = false; - dspjit = nullptr; g_dsp.irom = (u16*)AllocateMemoryPages(DSP_IROM_BYTE_SIZE); g_dsp.iram = (u16*)AllocateMemoryPages(DSP_IRAM_BYTE_SIZE); @@ -147,7 +147,7 @@ bool DSPCore_Init(const DSPInitOptions& opts) // Initialize JIT, if necessary if (opts.core_type == DSPInitOptions::CORE_JIT) - dspjit = new DSPEmitter(); + dspjit = std::make_unique(); g_dsp_cap.reset(opts.capture_logger); @@ -162,11 +162,7 @@ void DSPCore_Shutdown() core_state = DSPCORE_STOP; - if (dspjit) - { - delete dspjit; - dspjit = nullptr; - } + dspjit.reset(); DSPCore_FreeMemoryPages(); diff --git a/Source/Core/Core/DSP/DSPCore.h b/Source/Core/Core/DSP/DSPCore.h index a2c6de8451..c3452438e2 100644 --- a/Source/Core/Core/DSP/DSPCore.h +++ b/Source/Core/Core/DSP/DSPCore.h @@ -297,9 +297,9 @@ struct SDSP extern SDSP g_dsp; extern DSPBreakpoints dsp_breakpoints; -extern DSPEmitter *dspjit; extern u16 cyclesLeft; extern bool init_hax; +extern std::unique_ptr dspjit; extern std::unique_ptr g_dsp_cap; struct DSPInitOptions