Commit Diff


commit - e62fc5205c7c439d072229d8be922ea30e8d8024
commit + b43d5a6cd3a253c93c9cc25574997ac4aac7a4f9
blob - 764a86ea44c7cb639fc39ffdaca2a0f3db638d9e
blob + 994038a03f12d37d648f3e74efb26408dc0751a9
--- lib/delta_cache.c
+++ lib/delta_cache.c
@@ -158,8 +158,10 @@ delta_cache_resize(struct got_delta_cache *cache, unsi
 				new_delta = &head->entries[head->nchain];
 				memcpy(new_delta, delta, sizeof(*new_delta));
 				head->nchain++;
-			} else
+			} else {
 				free(delta->data);
+				cache->totelem--;
+			}
 		}
 	}
 
@@ -217,6 +219,8 @@ got_delta_cache_add(struct got_delta_cache *cache,
 		free(delta->data);
 		memset(delta, 0, sizeof(*delta));
 		head->nchain--;
+		cache->totelem--;
+		cache->cache_evict++;
 	}
 
 	delta = &head->entries[head->nchain];