X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=diff-delta.c;h=0dde2f2dc032863b154509f5b966cfafb01dd722;hb=10455d2a955a29db1809be139177e4e298771eb0;hp=17757d2af9576f4a340c5dbd62d30b597140ddba;hpb=41ffe5cdf5b0192cd70ef71b1cc37c7286d1dab0;p=git.git diff --git a/diff-delta.c b/diff-delta.c index 17757d2af..0dde2f2dc 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; @@ -211,7 +213,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) entry = hash[i]; do { struct index_entry *keep = entry; - int skip = hash_count[i] / HASH_LIMIT / 2; + int skip = hash_count[i] / HASH_LIMIT; do { entry = entry->next; } while(--skip && entry); @@ -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. @@ -388,7 +398,7 @@ create_delta(const struct delta_index *index, outsize = max_size + MAX_OP_SIZE + 1; if (max_size && outpos > max_size) break; - out = xrealloc(out, outsize); + out = realloc(out, outsize); if (!out) { free(tmp); return NULL;