diff options
| author | JosJuice <josjuice@gmail.com> | 2015-04-21 11:24:13 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-05-14 22:52:21 +0200 |
| commit | 405643b902b5b4ec84822551269dfede780b38c7 (patch) | |
| tree | d03a4a9a9fbf20000d606aadeafea7838fd00dcd /Source/Core/DiscIO/VolumeWiiCrypted.cpp | |
| parent | 5c46810a368e0739c403f6bb0e8c8c260be2464a (diff) | |
VolumeWiiCrypted: Use std::min
Diffstat (limited to 'Source/Core/DiscIO/VolumeWiiCrypted.cpp')
| -rw-r--r-- | Source/Core/DiscIO/VolumeWiiCrypted.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/VolumeWiiCrypted.cpp index b706c8e6f3..d37df8d9c7 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/VolumeWiiCrypted.cpp @@ -4,6 +4,7 @@ #include "DiscIO/VolumeWiiCrypted.h" +#include <algorithm> #include <cstddef> #include <cstring> #include <map> @@ -87,14 +88,14 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool de } // Copy the decrypted data - u64 MaxSizeToCopy = BLOCK_DATA_SIZE - data_offset_in_block; - u64 CopySize = (_Length > MaxSizeToCopy) ? MaxSizeToCopy : _Length; - memcpy(_pBuffer, &m_last_decrypted_block_data[data_offset_in_block], (size_t)CopySize); + u64 copy_size = std::min(_Length, BLOCK_DATA_SIZE - data_offset_in_block); + memcpy(_pBuffer, &m_last_decrypted_block_data[data_offset_in_block], + static_cast<size_t>(copy_size)); // Update offsets - _Length -= CopySize; - _pBuffer += CopySize; - _ReadOffset += CopySize; + _Length -= copy_size; + _pBuffer += copy_size; + _ReadOffset += copy_size; } return true; |
