comparison mercurial/bdiff.c @ 1978:10606ee61107

do proper typecasting on malloc() and calloc() calls to support build on Solaris 2.6 using Sun Pro SC4.0 (C++ 4.1) compiler.
author TK Soh <teekaysoh@yahoo.com>
date Mon, 20 Mar 2006 08:46:29 +0100
parents 5afd459db177
children
comparison
equal deleted inserted replaced
1977:7eb694a1c1af 1978:10606ee61107
72 i = 1; /* extra line for sentinel */ 72 i = 1; /* extra line for sentinel */
73 for (p = a; p < a + len; p++) 73 for (p = a; p < a + len; p++)
74 if (*p == '\n' || p == a + len - 1) 74 if (*p == '\n' || p == a + len - 1)
75 i++; 75 i++;
76 76
77 *lr = l = malloc(sizeof(struct line) * i); 77 *lr = l = (struct line *)malloc(sizeof(struct line) * i);
78 if (!l) 78 if (!l)
79 return -1; 79 return -1;
80 80
81 /* build the line array and calculate hashes */ 81 /* build the line array and calculate hashes */
82 h = 0; 82 h = 0;
111 111
112 /* build a hash table of the next highest power of 2 */ 112 /* build a hash table of the next highest power of 2 */
113 while (buckets < bn + 1) 113 while (buckets < bn + 1)
114 buckets *= 2; 114 buckets *= 2;
115 115
116 h = malloc(buckets * sizeof(struct pos)); 116 h = (struct pos *)malloc(buckets * sizeof(struct pos));
117 buckets = buckets - 1; 117 buckets = buckets - 1;
118 if (!h) 118 if (!h)
119 return 0; 119 return 0;
120 120
121 /* clear the hash table */ 121 /* clear the hash table */
235 struct pos *pos; 235 struct pos *pos;
236 int t; 236 int t;
237 237
238 /* allocate and fill arrays */ 238 /* allocate and fill arrays */
239 t = equatelines(a, an, b, bn); 239 t = equatelines(a, an, b, bn);
240 pos = calloc(bn, sizeof(struct pos)); 240 pos = (struct pos *)calloc(bn, sizeof(struct pos));
241 /* we can't have more matches than lines in the shorter file */ 241 /* we can't have more matches than lines in the shorter file */
242 l.head = l.base = malloc(sizeof(struct hunk) * ((an<bn ? an:bn) + 1)); 242 l.head = l.base = (struct hunk *)malloc(sizeof(struct hunk) *
243 ((an<bn ? an:bn) + 1));
243 244
244 if (pos && l.base && t) { 245 if (pos && l.base && t) {
245 /* generate the matching block list */ 246 /* generate the matching block list */
246 recurse(a, b, pos, 0, an, 0, bn, &l); 247 recurse(a, b, pos, 0, an, 0, bn, &l);
247 l.head->a1 = an; 248 l.head->a1 = an;