Skip to content

Commit

Permalink
pack-objects: fix delta cache size accounting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Dec 8, 2007
1 parent 2099bca commit b7a28f7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
}
}

trg_entry->delta = src_entry;
trg_entry->delta_size = delta_size;
trg->depth = src->depth + 1;

/*
* Handle memory allocation outside of the cache
* accounting lock. Compiler will optimize the strangeness
Expand All @@ -1439,14 +1435,18 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
trg_entry->delta_data = NULL;
}
if (delta_cacheable(src_size, trg_size, delta_size)) {
delta_cache_size += trg_entry->delta_size;
delta_cache_size += delta_size;
cache_unlock();
trg_entry->delta_data = xrealloc(delta_buf, delta_size);
} else {
cache_unlock();
free(delta_buf);
}

trg_entry->delta = src_entry;
trg_entry->delta_size = delta_size;
trg->depth = src->depth + 1;

return 1;
}

Expand Down

0 comments on commit b7a28f7

Please sign in to comment.