X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=diff-delta.c;h=8b9172aa2ef7402b0a847815bb11a26d1c4444fe;hb=f252281102514d8d3cc15a3df5ae633619c93835;hp=c61887518874d550f66d2d52bd7559d023fcb176;hpb=b9895c06882c0e395a2d22c3649e53bd342b535e;p=git.git diff --git a/diff-delta.c b/diff-delta.c index c61887518..8b9172aa2 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -22,6 +22,7 @@ #include #include "delta.h" +#include "git-compat-util.h" /* maximum hash entry list for the same hash bucket */ #define HASH_LIMIT 64 @@ -131,7 +132,7 @@ struct delta_index { const void *src_buf; unsigned long src_size; unsigned int hash_mask; - struct index_entry *hash[0]; + struct index_entry *hash[FLEX_ARRAY]; }; struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) @@ -199,7 +200,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) entry->next = hash[i]; hash[i] = entry++; hash_count[i]++; - entries--; } } @@ -230,10 +230,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) } free(hash_count); - /* If we didn't use all hash entries, free the unused memory. */ - if (entries) - index = realloc(index, memsize - entries * sizeof(*entry)); - return index; } @@ -288,7 +284,7 @@ create_delta(const struct delta_index *index, ref_data = index->src_buf; ref_top = ref_data + index->src_size; data = trg_buf; - top = trg_buf + trg_size; + top = (const unsigned char *) trg_buf + trg_size; outpos++; val = 0;