@matheusbsbs / matheus-bagliano / commits / b7a28f7827
Fork 0

pack-objects: fix delta cache size accounting

The wrong value was substracted from delta_cache_size when replacing a cached delta, as trg_entry->delta_size was used after the old size had been replaced by the new size. Noticed by Linus. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Dec 7, 2007 at 20:27 UTC b7a28f7827ba1043501fe357cbbdff3f2e357143
1 file changed +5 -5
builtin-pack-objects.c
+5 -5
@@ -1422,10 +1422,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1422 }
1423 }
1424
1425 - trg_entry->delta = src_entry;
1426 - trg_entry->delta_size = delta_size;
1427 - trg->depth = src->depth + 1;
1428 -
1425 /*
1426 * Handle memory allocation outside of the cache
1427 * accounting lock. Compiler will optimize the strangeness
@@ -1439,7 +1435,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1435 trg_entry->delta_data = NULL;
1436 }
1437 if (delta_cacheable(src_size, trg_size, delta_size)) {
1442 - delta_cache_size += trg_entry->delta_size;
1438 + delta_cache_size += delta_size;
1439 cache_unlock();
1440 trg_entry->delta_data = xrealloc(delta_buf, delta_size);
1441 } else {
@@ -1447,6 +1443,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1443 free(delta_buf);
1444 }
1445
1446 + trg_entry->delta = src_entry;
1447 + trg_entry->delta_size = delta_size;
1448 + trg->depth = src->depth + 1;
1449 +
1450 return 1;
1451 }
1452