Explorar o código

Fixed reloadpcdb (#7065)

Fixes #7063

Thanks to @kaninhot004
Lemongrass3110 %!s(int64=2) %!d(string=hai) anos
pai
achega
17d6381901
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/common/database.hpp

+ 3 - 1
src/common/database.hpp

@@ -183,8 +183,10 @@ public:
 
 			// Check if the key fits into the current cache size
 			if (this->cache.capacity() <= key) {
+				// Some keys compute to 0, so we allocate a minimum of 500 (250*2) entries
+				const static size_t minimum = 250;
 				// Double the current size, so we do not have to resize that often
-				size_t new_size = key * 2;
+				size_t new_size = std::max( key, minimum ) * 2;
 
 				// Very important => initialize everything to nullptr
 				this->cache.resize(new_size, nullptr);