+
+uint32_t pkgCache::CacheHash()
+{
+ pkgCache::Header header = {};
+ uLong adler = adler32(0L, Z_NULL, 0);
+
+ if (Map.Size() < sizeof(header))
+ return adler;
+ memcpy(&header, GetMap().Data(), sizeof(header));
+
+ header.Dirty = false;
+ header.CacheFileSize = 0;
+
+ adler = adler32(adler,
+ reinterpret_cast<const unsigned char *>(&header),
+ sizeof(header));
+
+ if (Map.Size() > sizeof(header)) {
+ adler = adler32(adler,
+ static_cast<const unsigned char *>(GetMap().Data()) + sizeof(header),
+ GetMap().Size() - sizeof(header));
+ }
+
+ return adler;
+}