summaryrefslogtreecommitdiff
path: root/diff-delta.c
diff options
context:
space:
mode:
authorBrian Downing <bdowning@lavos.net>2007-07-12 07:55:48 -0500
committerJunio C Hamano <gitster@pobox.com>2007-07-12 14:32:35 -0700
commit11779e79078c9da604753e570d02134c8d4bae6a (patch)
tree27449276ffd360c6947fe778d526934b6348a12f /diff-delta.c
parenta1dab41af4c575bb72231c73df26ecb2af4814d6 (diff)
downloadgit-11779e79078c9da604753e570d02134c8d4bae6a.tar.gz
Support fetching the memory usage of a delta index
Delta indices, at least on 64-bit platforms, tend to be larger than the actual uncompressed data. As such, keeping track of this storage is important if you want to successfully limit the memory size of your pack window. Squirrel away the total allocation size inside the delta_index struct, and add an accessor "sizeof_delta_index" to access it. Signed-off-by: Brian Downing <bdowning@lavos.net> Acked-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-delta.c')
-rw-r--r--diff-delta.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/diff-delta.c b/diff-delta.c
index faf96e4713..3af583536f 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -119,6 +119,7 @@ struct index_entry {
};
struct delta_index {
+ unsigned long memsize;
const void *src_buf;
unsigned long src_size;
unsigned int hash_mask;
@@ -159,6 +160,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
mem = hash + hsize;
entry = mem;
+ index->memsize = memsize;
index->src_buf = buf;
index->src_size = bufsize;
index->hash_mask = hmask;
@@ -228,6 +230,14 @@ void free_delta_index(struct delta_index *index)
free(index);
}
+unsigned long sizeof_delta_index(struct delta_index *index)
+{
+ if (index)
+ return index->memsize;
+ else
+ return 0;
+}
+
/*
* The maximum size for any opcode sequence, including the initial header
* plus Rabin window plus biggest copy.