From 1d01fbd2175968dea6e7e0fcf4ba6bfb83bf32b8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Dec 2015 07:21:51 -0500 Subject: [PATCH] HiresTextures: Make Load return a unique_ptr --- Source/Core/VideoCommon/HiresTextures.cpp | 12 ++++++------ Source/Core/VideoCommon/HiresTextures.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp index a552b63f39..60123b9cce 100644 --- a/Source/Core/VideoCommon/HiresTextures.cpp +++ b/Source/Core/VideoCommon/HiresTextures.cpp @@ -167,11 +167,11 @@ void HiresTexture::Prefetch() // But bad luck, SOIL isn't, so TODO: remove SOIL usage here and use libpng directly // Also TODO: remove s_textureCacheAquireMutex afterwards. It won't be needed as the main mutex will be locked rarely //lk.unlock(); - HiresTexture* t = Load(base_filename, 0, 0); + std::unique_ptr texture = Load(base_filename, 0, 0); //lk.lock(); - if (t) + if (texture) { - std::shared_ptr ptr(t); + std::shared_ptr ptr(std::move(texture)); iter = s_textureCache.insert(iter, std::make_pair(base_filename, ptr)); } } @@ -366,9 +366,9 @@ std::shared_ptr HiresTexture::Search(const u8* texture, size_t tex return ptr; } -HiresTexture* HiresTexture::Load(const std::string& base_filename, u32 width, u32 height) +std::unique_ptr HiresTexture::Load(const std::string& base_filename, u32 width, u32 height) { - HiresTexture* ret = nullptr; + std::unique_ptr ret; for (int level = 0;; level++) { std::string filename = base_filename; @@ -420,7 +420,7 @@ HiresTexture* HiresTexture::Load(const std::string& base_filename, u32 width, u3 height >>= 1; if (!ret) - ret = new HiresTexture(); + ret = std::unique_ptr(new HiresTexture); ret->m_levels.push_back(l); } else diff --git a/Source/Core/VideoCommon/HiresTextures.h b/Source/Core/VideoCommon/HiresTextures.h index 984b273ec1..51961354b7 100644 --- a/Source/Core/VideoCommon/HiresTextures.h +++ b/Source/Core/VideoCommon/HiresTextures.h @@ -43,7 +43,7 @@ public: std::vector m_levels; private: - static HiresTexture* Load(const std::string& base_filename, u32 width, u32 height); + static std::unique_ptr Load(const std::string& base_filename, u32 width, u32 height); static void Prefetch(); HiresTexture() {}