From 5b6f604d90fe15b9453171a1ec8ce2683437a6ee Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 20 Oct 2020 11:33:38 +0200 Subject: [PATCH] DiscIO: Make WiiEncryptionCache moveable Fixes the following warning: ../../../../../../Core\DiscIO/DirectoryBlob.h:156:3: warning: explicitly defaulted move constructor is implicitly deleted [-Wdefaulted-function-deleted] DirectoryBlobReader(DirectoryBlobReader&&) = default; ^ ../../../../../../Core\DiscIO/DirectoryBlob.h:205:22: note: move constructor of 'DirectoryBlobReader' is implicitly deleted because field 'm_encryption_cache' has a deleted move constructor WiiEncryptionCache m_encryption_cache; ^ --- Source/Core/DiscIO/WiiEncryptionCache.cpp | 3 +++ Source/Core/DiscIO/WiiEncryptionCache.h | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/DiscIO/WiiEncryptionCache.cpp b/Source/Core/DiscIO/WiiEncryptionCache.cpp index 52d978761e..68a307c956 100644 --- a/Source/Core/DiscIO/WiiEncryptionCache.cpp +++ b/Source/Core/DiscIO/WiiEncryptionCache.cpp @@ -29,7 +29,10 @@ WiiEncryptionCache::EncryptGroup(u64 offset, u64 partition_data_offset, { // Only allocate memory if this function actually ends up getting called if (!m_cache) + { m_cache = std::make_unique>(); + m_cached_offset = std::numeric_limits::max(); + } ASSERT(offset % VolumeWii::GROUP_TOTAL_SIZE == 0); const u64 group_offset_in_partition = diff --git a/Source/Core/DiscIO/WiiEncryptionCache.h b/Source/Core/DiscIO/WiiEncryptionCache.h index d0a48b054d..a5215e4573 100644 --- a/Source/Core/DiscIO/WiiEncryptionCache.h +++ b/Source/Core/DiscIO/WiiEncryptionCache.h @@ -26,6 +26,14 @@ public: explicit WiiEncryptionCache(BlobReader* blob); ~WiiEncryptionCache(); + WiiEncryptionCache(WiiEncryptionCache&&) = default; + WiiEncryptionCache& operator=(WiiEncryptionCache&&) = default; + + // It would be possible to write a custom copy constructor and assignment operator + // for this class, but there has been no reason to do so. + WiiEncryptionCache(const WiiEncryptionCache&) = delete; + WiiEncryptionCache& operator=(const WiiEncryptionCache&) = delete; + // Encrypts exactly one group. // If the returned pointer is nullptr, reading from the blob failed. // If the returned pointer is not nullptr, it is guaranteed to be valid until @@ -43,7 +51,7 @@ public: private: BlobReader* m_blob; std::unique_ptr> m_cache; - u64 m_cached_offset = std::numeric_limits::max(); + u64 m_cached_offset; }; } // namespace DiscIO