mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
3d662e746b
This moves the only direct call to zlib’s crc32() into its own translation unit, but that operation is cold enough that this won’t matter in the slightest. crc32_z() would be more appropriate, but Android has an older zlib version…
20 lines
470 B
C++
20 lines
470 B
C++
// Copyright 2021 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <zlib.h>
|
|
|
|
#include "Common/CRC32.h"
|
|
|
|
namespace Common
|
|
{
|
|
u32 ComputeCRC32(std::string_view data)
|
|
{
|
|
const Bytef* buf = reinterpret_cast<const Bytef*>(data.data());
|
|
uInt len = static_cast<uInt>(data.size());
|
|
// Use zlibs crc32 implementation to compute the hash
|
|
u32 hash = crc32(0L, Z_NULL, 0);
|
|
hash = crc32(hash, buf, len);
|
|
return hash;
|
|
}
|
|
} // namespace Common
|