X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=diff-delta.c;h=9f998d0a73e0127d3a68a7caecb3727569149871;hb=204d409247e7bbc7848569462aa11a87e373c8d6;hp=74486b1b81419d0078d8f1e43c96db437d6d4f65;hpb=9e37f72afe49c133bfc54b17b659b2ae6f189b7f;p=thirdparty%2Fgit.git diff --git a/diff-delta.c b/diff-delta.c index 74486b1b81..9f998d0a73 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -18,11 +18,8 @@ * licensing gets turned into GPLv2 within this project. */ -#include -#include -#include "delta.h" - #include "git-compat-util.h" +#include "delta.h" /* maximum hash entry list for the same hash bucket */ #define HASH_LIMIT 64 @@ -148,11 +145,11 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) return NULL; /* Determine index hash size. Note that indexing skips the - first byte to allow for optimizing the rabin polynomial + first byte to allow for optimizing the Rabin's polynomial initialization in create_delta(). */ entries = (bufsize - 1) / RABIN_WINDOW; hsize = entries / 4; - for (i = 4; (1 << i) < hsize && i < 31; i++); + for (i = 4; (1u << i) < hsize && i < 31; i++); hsize = 1 << i; hmask = hsize - 1; @@ -205,7 +202,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) /* * Determine a limit on the number of entries in the same hash - * bucket. This guard us against patological data sets causing + * bucket. This guards us against pathological data sets causing * really bad hash distribution with most entries in the same hash * bucket that would bring us to O(m*n) computing costs (m and n * corresponding to reference and target buffer sizes). @@ -240,7 +237,7 @@ void free_delta_index(struct delta_index *index) /* * The maximum size for any opcode sequence, including the initial header - * plus rabin window plus biggest copy. + * plus Rabin window plus biggest copy. */ #define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7) @@ -284,7 +281,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; @@ -392,7 +389,7 @@ create_delta(const struct delta_index *index, outsize = max_size + MAX_OP_SIZE + 1; if (max_size && outpos > max_size) break; - out = realloc(out, outsize); + out = xrealloc(out, outsize); if (!out) { free(tmp); return NULL;