diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-12-22 19:59:32 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-12-22 20:09:54 -0500 |
| commit | 8371c428cd1c3646776743f8da4bdf8c827ed487 (patch) | |
| tree | b01710ce88d5401330459644ab064c57c1bb7033 /Source/Core/VideoCommon/VertexLoaderBase.cpp | |
| parent | 3cf16f85738bbcff0a5c4027f26adf30f548bb59 (diff) | |
VertexLoaderBase: Get rid of explicit delete and new
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderBase.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp index 7db8c22b8a..94d4f600ae 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.cpp +++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <cinttypes> +#include <memory> #include <vector> #include "Common/Common.h" @@ -130,8 +131,8 @@ void VertexLoaderBase::AppendToString(std::string *dest) const class VertexLoaderTester : public VertexLoaderBase { public: - VertexLoaderTester(VertexLoaderBase* _a, VertexLoaderBase* _b, const TVtxDesc& vtx_desc, const VAT& vtx_attr) - : VertexLoaderBase(vtx_desc, vtx_attr), a(_a), b(_b) + VertexLoaderTester(std::unique_ptr<VertexLoaderBase> a_, std::unique_ptr<VertexLoaderBase> b_, const TVtxDesc& vtx_desc, const VAT& vtx_attr) + : VertexLoaderBase(vtx_desc, vtx_attr), a(std::move(a_)), b(std::move(b_)) { m_initialized = a && b && a->IsInitialized() && b->IsInitialized(); @@ -159,8 +160,6 @@ public: } ~VertexLoaderTester() override { - delete a; - delete b; } int RunVertices(DataReader src, DataReader dst, int count) override @@ -187,43 +186,43 @@ public: bool IsInitialized() override { return m_initialized; } private: - VertexLoaderBase *a, *b; bool m_initialized; - std::vector<u8> buffer_a, buffer_b; + + std::unique_ptr<VertexLoaderBase> a; + std::unique_ptr<VertexLoaderBase> b; + + std::vector<u8> buffer_a; + std::vector<u8> buffer_b; }; -VertexLoaderBase* VertexLoaderBase::CreateVertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr) +std::unique_ptr<VertexLoaderBase> VertexLoaderBase::CreateVertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr) { - VertexLoaderBase* loader; + std::unique_ptr<VertexLoaderBase> loader; //#define COMPARE_VERTEXLOADERS #if defined(COMPARE_VERTEXLOADERS) && defined(_M_X86_64) // first try: Any new VertexLoader vs the old one - loader = new VertexLoaderTester( - new VertexLoader(vtx_desc, vtx_attr), // the software one - new VertexLoaderX64(vtx_desc, vtx_attr), // the new one to compare + loader = std::make_unique<VertexLoaderTester>( + std::make_unique<VertexLoader>(vtx_desc, vtx_attr), // the software one + std::make_unique<VertexLoaderX64>(vtx_desc, vtx_attr), // the new one to compare vtx_desc, vtx_attr); if (loader->IsInitialized()) return loader; - delete loader; #elif defined(_M_X86_64) - loader = new VertexLoaderX64(vtx_desc, vtx_attr); + loader = std::make_unique<VertexLoaderX64>(vtx_desc, vtx_attr); if (loader->IsInitialized()) return loader; - delete loader; #elif defined(_M_ARM_64) - loader = new VertexLoaderARM64(vtx_desc, vtx_attr); + loader = std::make_unique<VertexLoaderARM64>(vtx_desc, vtx_attr); if (loader->IsInitialized()) return loader; - delete loader; #endif // last try: The old VertexLoader - loader = new VertexLoader(vtx_desc, vtx_attr); + loader = std::make_unique<VertexLoader>(vtx_desc, vtx_attr); if (loader->IsInitialized()) return loader; - delete loader; PanicAlert("No Vertex Loader found."); return nullptr; |
