diff --git a/Utilities/JIT.h b/Utilities/JIT.h index 24c27d068d..d24a7f0ed0 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -8,6 +8,7 @@ #include "types.h" +#include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) #endif @@ -17,6 +18,7 @@ #ifdef _MSC_VER #pragma warning(pop) #endif +#include "define_new_memleakdetect.h" extern llvm::LLVMContext g_llvm_ctx; diff --git a/Utilities/rXml.cpp b/Utilities/rXml.cpp index 650cdf50fa..be52679cd6 100644 --- a/Utilities/rXml.cpp +++ b/Utilities/rXml.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" +#include "restore_new.h" #include "Utilities/rXml.h" +#include "define_new_memleakdetect.h" rXmlNode::rXmlNode() : handle() { diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 30b66881c6..c7fb7869b9 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -263,9 +263,9 @@ s32 pngDecCreate(ppu_thread& ppu, PPHandle png_handle, PThreadInParam thread_in_ } // Set the allocation functions in the handle - handle->malloc = thread_in_param->cbCtrlMallocFunc; + handle->malloc_ = thread_in_param->cbCtrlMallocFunc; handle->malloc_arg = thread_in_param->cbCtrlMallocArg; - handle->free = thread_in_param->cbCtrlFreeFunc; + handle->free_ = thread_in_param->cbCtrlFreeFunc; handle->free_arg = thread_in_param->cbCtrlFreeArg; // Set handle pointer @@ -280,7 +280,7 @@ s32 pngDecCreate(ppu_thread& ppu, PPHandle png_handle, PThreadInParam thread_in_ s32 pngDecDestroy(ppu_thread& ppu, PHandle handle) { // Deallocate the decoder handle memory - if (handle->free(ppu, handle, handle->free_arg) != 0) + if (handle->free_(ppu, handle, handle->free_arg) != 0) { cellPngDec.error("PNG decoder deallocation failed."); return CELL_PNGDEC_ERROR_FATAL; @@ -298,7 +298,7 @@ s32 pngDecOpen(ppu_thread& ppu, PHandle handle, PPStream png_stream, PSrc source } // Allocate memory for the stream structure - auto stream = vm::ptr::make(handle->malloc(ppu, sizeof(PngStream), handle->malloc_arg).addr()); + auto stream = vm::ptr::make(handle->malloc_(ppu, sizeof(PngStream), handle->malloc_arg).addr()); // Check if the allocation of memory for the stream structure failed if (!stream) @@ -320,7 +320,7 @@ s32 pngDecOpen(ppu_thread& ppu, PHandle handle, PPStream png_stream, PSrc source *png_stream = stream; // Allocate memory for the PNG buffer for decoding - auto buffer = vm::ptr::make(handle->malloc(ppu, sizeof(PngBuffer), handle->malloc_arg).addr()); + auto buffer = vm::ptr::make(handle->malloc_(ppu, sizeof(PngBuffer), handle->malloc_arg).addr()); // Check for if the buffer structure allocation failed if (!buffer) @@ -453,7 +453,7 @@ s32 pngDecClose(ppu_thread& ppu, PHandle handle, PStream stream) // Deallocate the PNG buffer structure used to decode from memory, if we decoded from memory if (stream->buffer) { - if (handle->free(ppu, stream->buffer, handle->free_arg) != 0) + if (handle->free_(ppu, stream->buffer, handle->free_arg) != 0) { cellPngDec.error("PNG buffer decoding structure deallocation failed."); return CELL_PNGDEC_ERROR_FATAL; @@ -464,7 +464,7 @@ s32 pngDecClose(ppu_thread& ppu, PHandle handle, PStream stream) png_destroy_read_struct(&stream->png_ptr, &stream->info_ptr, nullptr); // Deallocate the stream memory - if (handle->free(ppu, stream, handle->free_arg) != 0) + if (handle->free_(ppu, stream, handle->free_arg) != 0) { cellPngDec.error("PNG stream deallocation failed."); return CELL_PNGDEC_ERROR_FATAL; diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.h b/rpcs3/Emu/Cell/Modules/cellPngDec.h index 4cd24a2904..a56d9457da 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.h +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.h @@ -264,9 +264,9 @@ struct CellPngDecCbCtrlDisp // Custom structs struct PngHandle { - vm::ptr malloc; + vm::ptr malloc_; vm::ptr malloc_arg; - vm::ptr free; + vm::ptr free_; vm::ptr free_arg; }; diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index ade8f9a1b0..f88c1dec79 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -3,7 +3,9 @@ #include "Emu/IdManager.h" #include "Emu/Cell/PPUModule.h" +#include "restore_new.h" #include "Utilities/rXml.h" +#include "define_new_memleakdetect.h" #include "Loader/TRP.h" #include "Loader/TROPUSR.h" diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index b693e01c6f..f5a9ca7c89 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -10,6 +10,7 @@ #include "PPUModule.h" #ifdef LLVM_AVAILABLE +#include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) #endif @@ -35,6 +36,7 @@ #ifdef _MSC_VER #pragma warning(pop) #endif +#include "define_new_memleakdetect.h" #include "Utilities/JIT.h" #include "PPUTranslator.h" diff --git a/rpcs3/Emu/Cell/PPUTranslator.h b/rpcs3/Emu/Cell/PPUTranslator.h index 5c36ee029b..e38009bdd8 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.h +++ b/rpcs3/Emu/Cell/PPUTranslator.h @@ -11,6 +11,7 @@ #include "../rpcs3/Emu/Cell/PPUOpcodes.h" #include "../rpcs3/Emu/Cell/PPUAnalyser.h" +#include "restore_new.h" #ifdef _MSC_VER #pragma warning(push, 0) #endif @@ -20,6 +21,7 @@ #ifdef _MSC_VER #pragma warning(pop) #endif +#include "define_new_memleakdetect.h" #include "../Utilities/types.h" #include "../Utilities/StrFmt.h" diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp index 0a2e93ea37..8d2aa93e5f 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp @@ -442,7 +442,7 @@ u32 arm_tls_manager::alloc() return 0; } -void arm_tls_manager::free(u32 addr) +void arm_tls_manager::dealloc(u32 addr) { if (!addr) { @@ -555,7 +555,7 @@ error_code sceKernelDeleteThread(s32 threadId) // return SCE_KERNEL_ERROR_NOT_DORMANT; //} - fxm::get()->free(thread->TLS); + fxm::get()->dealloc(thread->TLS); idm::remove(threadId); return SCE_OK; } @@ -567,7 +567,7 @@ error_code sceKernelExitDeleteThread(ARMv7Thread& cpu, s32 exitStatus) //cpu.state += cpu_flag::stop; // Delete current thread; exit status is stored in r0 - fxm::get()->free(cpu.TLS); + fxm::get()->dealloc(cpu.TLS); idm::remove(cpu.id); return SCE_OK; diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.h b/rpcs3/Emu/PSP2/Modules/sceLibKernel.h index 6e82fe5e60..7300016e90 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.h +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.h @@ -21,7 +21,7 @@ public: u32 alloc(); // Deallocate by address - void free(u32 addr); + void dealloc(u32 addr); }; // Error Codes diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp index 27aa74e184..40644fd83d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp @@ -7,7 +7,9 @@ #include "../Common/BufferUtils.h" #include "D3D12Formats.h" #include "../rsx_methods.h" -#include +#include "restore_new.h" +#include "Utilities/variant.hpp" +#include "define_new_memleakdetect.h" namespace { diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.h b/rpcs3/Emu/RSX/GL/GLGSRender.h index ce25905c53..d2022e8b60 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.h +++ b/rpcs3/Emu/RSX/GL/GLGSRender.h @@ -4,7 +4,9 @@ #include "GLTexture.h" #include "GLTextureCache.h" #include "GLRenderTargets.h" -#include +#include "restore_new.h" +#include "Utilities/optional.hpp" +#include "define_new_memleakdetect.h" #include "GLProgramBuffer.h" #include "GLTextOut.h" diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 213fafde71..3c48e8d2d3 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -17,7 +17,9 @@ #include "Utilities/Timer.h" #include "Utilities/geometry.h" #include "rsx_trace.h" +#include "restore_new.h" #include "Utilities/variant.hpp" +#include "define_new_memleakdetect.h" extern u64 get_system_time(); diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index 7405b1e6a3..3eb4804932 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "VKCommonDecompiler.h" +#include "restore_new.h" #include "../../../../Vulkan/glslang/SPIRV/GlslangToSpv.h" +#include "define_new_memleakdetect.h" namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.h b/rpcs3/Emu/RSX/VK/VKGSRender.h index 9cb9e8b961..64d5a6ef75 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.h +++ b/rpcs3/Emu/RSX/VK/VKGSRender.h @@ -5,7 +5,9 @@ #include "VKRenderTargets.h" #include "VKFormats.h" #include "VkTextOut.h" -#include +#include "restore_new.h" +#include "Utilities/optional.hpp" +#include "define_new_memleakdetect.h" #define RSX_DEBUG 1 diff --git a/rpcs3/Emu/RSX/VK/VulkanAPI.h b/rpcs3/Emu/RSX/VK/VulkanAPI.h index 622d3b3803..2b3b03a9eb 100644 --- a/rpcs3/Emu/RSX/VK/VulkanAPI.h +++ b/rpcs3/Emu/RSX/VK/VulkanAPI.h @@ -6,8 +6,10 @@ #define VK_USE_PLATFORM_XLIB_KHR #endif +#include "restore_new.h" #include #include +#include "define_new_memleakdetect.h" #include "Utilities/types.h" namespace vk diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index dee75a46d6..914f88a8d6 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" +#include "restore_new.h" #include "Utilities/rXml.h" +#include "define_new_memleakdetect.h" #include "Emu/System.h" #include "TROPUSR.h"