Made the types used in the sum_buf and sum_struct structures consistent
[rsync/rsync.git] / match.c
diff --git a/match.c b/match.c
index 459eb6d..1c7794a 100644 (file)
--- a/match.c
+++ b/match.c
@@ -62,9 +62,9 @@ static void build_hash_table(struct sum_struct *s)
        int i;
 
        if (!tag_table)
-               tag_table = (int *)malloc(sizeof(tag_table[0])*TABLESIZE);
+               tag_table = new_array(int, TABLESIZE);
 
-       targets = (struct target *)malloc(sizeof(targets[0])*s->count);
+       targets = new_array(struct target, s->count);
        if (!tag_table || !targets)
                out_of_memory("build_hash_table");
 
@@ -105,7 +105,7 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
        OFF_T j;
 
        if (verbose > 2 && i >= 0)
-               rprintf(FINFO,"match at %.0f last_match=%.0f j=%d len=%d n=%.0f\n",
+               rprintf(FINFO,"match at %.0f last_match=%.0f j=%d len=%u n=%.0f\n",
                        (double)offset,(double)last_match,i,s->sums[i].len,(double)n);
 
        send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len);
@@ -136,7 +136,7 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
 
 
 static void hash_search(int f,struct sum_struct *s,
-                       struct map_struct *buf,OFF_T len)
+                       struct map_struct *buf, OFF_T len)
 {
        OFF_T offset, end;
        int j,k, last_i;
@@ -152,9 +152,7 @@ static void hash_search(int f,struct sum_struct *s,
                rprintf(FINFO,"hash search b=%ld len=%.0f\n",
                        (long) s->blength, (double)len);
 
-       /* cast is to make s->blength signed; it should always be reasonably
-        * small */
-       k = MIN(len, (OFF_T) s->blength);
+       k = MIN(len, (OFF_T)s->blength);
 
        map = (schar *)map_ptr(buf,0,k);
 
@@ -187,12 +185,13 @@ static void hash_search(int f,struct sum_struct *s,
                sum = (s1 & 0xffff) | (s2 << 16);
                tag_hits++;
                for (; j < (int) s->count && targets[j].t == t; j++) {
-                       int l, i = targets[j].i;
+                       unsigned int l;
+                       int i = targets[j].i;
 
                        if (sum != s->sums[i].sum1) continue;
 
                        /* also make sure the two blocks are the same length */
-                       l = MIN(s->blength,len-offset);
+                       l = MIN((OFF_T)s->blength, len-offset);
                        if (l != s->sums[i].len) continue;
 
                        if (verbose > 3)
@@ -228,7 +227,7 @@ static void hash_search(int f,struct sum_struct *s,
 
                        matched(f,s,buf,offset,i);
                        offset += s->sums[i].len - 1;
-                       k = MIN((len-offset), s->blength);
+                       k = MIN((OFF_T)s->blength, len-offset);
                        map = (schar *)map_ptr(buf,offset,k);
                        sum = get_checksum1((char *)map, k);
                        s1 = sum & 0xFFFF;
@@ -286,7 +285,7 @@ static void hash_search(int f,struct sum_struct *s,
 void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
 {
        char file_sum[MD4_SUM_LENGTH];
-       extern int write_batch;  /*  dw */
+       extern int write_batch;
 
        last_match = 0;
        false_alarms = 0;
@@ -321,7 +320,7 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
        if (verbose > 2)
                rprintf(FINFO,"sending file_sum\n");
        write_buf(f,file_sum,MD4_SUM_LENGTH);
-       if (write_batch) /* dw */
+       if (write_batch)
                write_batch_delta_file(file_sum, MD4_SUM_LENGTH);
 
        if (targets) {