tools/lru_cache: make minimum capacity 1
Setting this to 0 is not just useless, but breaks the logic horribly enough to cause random segfaults - better forbid this, to avoid someone else having to debug it again ;) Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
		
				
					committed by
					
						 Wolfgang Bumiller
						Wolfgang Bumiller
					
				
			
			
				
	
			
			
			
						parent
						
							da78b90f9c
						
					
				
				
					commit
					4121628d99
				
			| @ -106,6 +106,7 @@ unsafe impl<K: Send, V: Send> Send for LruCache<K, V> {} | ||||
| impl<K: std::cmp::Eq + std::hash::Hash + Copy, V> LruCache<K, V> { | ||||
|     /// Create LRU cache instance which holds up to `capacity` nodes at once. | ||||
|     pub fn new(capacity: usize) -> Self { | ||||
|         let capacity = capacity.min(1); | ||||
|         Self { | ||||
|             map: HashMap::with_capacity(capacity), | ||||
|             list: LinkedList::new(), | ||||
|  | ||||
		Reference in New Issue
	
	Block a user