mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Replace remaining uses of zlib crc32 with Common/Hash.h
This commit is contained in:
@ -534,11 +534,25 @@ void SetHash64Function()
|
||||
|
||||
u32 ComputeCRC32(std::string_view data)
|
||||
{
|
||||
const Bytef* buf = reinterpret_cast<const Bytef*>(data.data());
|
||||
uInt len = static_cast<uInt>(data.size());
|
||||
return ComputeCRC32(reinterpret_cast<const u8*>(data.data()), static_cast<u32>(data.size()));
|
||||
}
|
||||
|
||||
u32 ComputeCRC32(const u8* ptr, u32 length)
|
||||
{
|
||||
return UpdateCRC32(StartCRC32(), ptr, length);
|
||||
}
|
||||
|
||||
u32 StartCRC32()
|
||||
{
|
||||
return crc32(0L, Z_NULL, 0);
|
||||
}
|
||||
|
||||
u32 UpdateCRC32(u32 crc, const u8* ptr, u32 length)
|
||||
{
|
||||
static_assert(std::is_same_v<const u8*, const Bytef*>);
|
||||
static_assert(std::is_same_v<u32, uInt>);
|
||||
// Use zlib's crc32 implementation to compute the hash
|
||||
u32 hash = crc32(0L, Z_NULL, 0);
|
||||
hash = crc32(hash, buf, len);
|
||||
return hash;
|
||||
// crc32_z (which takes a size_t) would be better, but it isn't available on Android
|
||||
return crc32(crc, ptr, length);
|
||||
}
|
||||
} // namespace Common
|
||||
|
Reference in New Issue
Block a user