123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #ifndef LIBMEMUNREACHABLE_LEAK_H_
- #define LIBMEMUNREACHABLE_LEAK_H_
- #include <functional>
- #include <vector>
- #include "memunreachable/memunreachable.h"
- namespace std {
- template <>
- struct hash<android::Leak::Backtrace> {
- std::size_t operator()(const android::Leak::Backtrace& key) const {
- std::size_t seed = 0;
- hash_combine(seed, key.num_frames);
- for (size_t i = 0; i < key.num_frames; i++) {
- hash_combine(seed, key.frames[i]);
- }
- return seed;
- }
- private:
- template <typename T>
- inline void hash_combine(std::size_t& seed, const T& v) const {
- std::hash<T> hasher;
- seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
- }
- };
- }
- namespace android {
- static bool operator==(const Leak::Backtrace& lhs, const Leak::Backtrace& rhs) {
- return (lhs.num_frames == rhs.num_frames) &&
- memcmp(lhs.frames, rhs.frames, lhs.num_frames * sizeof(lhs.frames[0])) == 0;
- }
- }
- #endif
|