Commit 38ce8e33 authored by Michael Reeves's avatar Michael Reeves

Fix weird sizeof syntax

parent 418ea78c
...@@ -400,7 +400,7 @@ void GnuDiff::discard_confusing_lines(struct file_data filevec[]) ...@@ -400,7 +400,7 @@ void GnuDiff::discard_confusing_lines(struct file_data filevec[])
LineRef *p; LineRef *p;
/* Allocate our results. */ /* Allocate our results. */
p = (LineRef *)xmalloc((filevec[0].buffered_lines + filevec[1].buffered_lines) * (2 * sizeof *p)); p = (LineRef *)xmalloc((filevec[0].buffered_lines + filevec[1].buffered_lines) * (2 * sizeof(*p)));
for(f = 0; f < 2; ++f) for(f = 0; f < 2; ++f)
{ {
filevec[f].undiscarded = p; filevec[f].undiscarded = p;
...@@ -412,7 +412,7 @@ void GnuDiff::discard_confusing_lines(struct file_data filevec[]) ...@@ -412,7 +412,7 @@ void GnuDiff::discard_confusing_lines(struct file_data filevec[])
/* Set up equiv_count[F][I] as the number of lines in file F /* Set up equiv_count[F][I] as the number of lines in file F
that fall in equivalence class I. */ that fall in equivalence class I. */
p = (LineRef *)zalloc(filevec[0].equiv_max * (2 * sizeof *p)); p = (LineRef *)zalloc(filevec[0].equiv_max * (2 * sizeof(*p)));
equiv_count[0] = p; equiv_count[0] = p;
equiv_count[1] = p + filevec[0].equiv_max; equiv_count[1] = p + filevec[0].equiv_max;
...@@ -704,7 +704,7 @@ void GnuDiff::shift_boundaries(struct file_data filevec[]) ...@@ -704,7 +704,7 @@ void GnuDiff::shift_boundaries(struct file_data filevec[])
GnuDiff::change *GnuDiff::add_change(LineRef line0, LineRef line1, LineRef deleted, LineRef inserted, struct change *old) GnuDiff::change *GnuDiff::add_change(LineRef line0, LineRef line1, LineRef deleted, LineRef inserted, struct change *old)
{ {
struct change *newChange = (change *)xmalloc(sizeof *newChange); struct change *newChange = (change *)xmalloc(sizeof(*newChange));
newChange->line0 = line0; newChange->line0 = line0;
newChange->line1 = line1; newChange->line1 = line1;
...@@ -815,7 +815,7 @@ GnuDiff::change *GnuDiff::diff_2_files(struct comparison *cmp) ...@@ -815,7 +815,7 @@ GnuDiff::change *GnuDiff::diff_2_files(struct comparison *cmp)
xvec = cmp->file[0].undiscarded; xvec = cmp->file[0].undiscarded;
yvec = cmp->file[1].undiscarded; yvec = cmp->file[1].undiscarded;
diags = (cmp->file[0].nondiscarded_lines + cmp->file[1].nondiscarded_lines + 3); diags = (cmp->file[0].nondiscarded_lines + cmp->file[1].nondiscarded_lines + 3);
fdiag = (LineRef *)xmalloc(diags * (2 * sizeof *fdiag)); fdiag = (LineRef *)xmalloc(diags * (2 * sizeof(*fdiag)));
bdiag = fdiag + diags; bdiag = fdiag + diags;
fdiag += cmp->file[1].nondiscarded_lines + 1; fdiag += cmp->file[1].nondiscarded_lines + 1;
bdiag += cmp->file[1].nondiscarded_lines + 1; bdiag += cmp->file[1].nondiscarded_lines + 1;
......
...@@ -201,7 +201,7 @@ class GnuDiff ...@@ -201,7 +201,7 @@ class GnuDiff
const QChar *buffer; const QChar *buffer;
/* Allocated size of buffer, in QChars. Always a multiple of /* Allocated size of buffer, in QChars. Always a multiple of
sizeof *buffer. */ sizeof(*buffer). */
size_t bufsize; size_t bufsize;
/* Number of valid bytes now in the buffer. */ /* Number of valid bytes now in the buffer. */
......
...@@ -142,7 +142,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current) ...@@ -142,7 +142,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
LineRef alloc_lines = current->alloc_lines; LineRef alloc_lines = current->alloc_lines;
LineRef line = 0; LineRef line = 0;
LineRef linbuf_base = current->linbuf_base; LineRef linbuf_base = current->linbuf_base;
LineRef *cureqs = (LineRef *)xmalloc(alloc_lines * sizeof *cureqs); LineRef *cureqs = (LineRef *)xmalloc(alloc_lines * sizeof(*cureqs));
struct equivclass *eqs = equivs; struct equivclass *eqs = equivs;
LineRef eqs_index = equivs_index; LineRef eqs_index = equivs_index;
LineRef eqs_alloc = equivs_alloc; LineRef eqs_alloc = equivs_alloc;
...@@ -212,10 +212,10 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current) ...@@ -212,10 +212,10 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
i = eqs_index++; i = eqs_index++;
if(i == eqs_alloc) if(i == eqs_alloc)
{ {
if((LineRef)(LINEREF_MAX / (2 * sizeof *eqs)) <= eqs_alloc) if((LineRef)(LINEREF_MAX / (2 * sizeof(*eqs))) <= eqs_alloc)
xalloc_die(); xalloc_die();
eqs_alloc *= 2; eqs_alloc *= 2;
eqs = (equivclass *)xrealloc(eqs, eqs_alloc * sizeof *eqs); eqs = (equivclass *)xrealloc(eqs, eqs_alloc * sizeof(*eqs));
} }
eqs[i].next = *bucket; eqs[i].next = *bucket;
eqs[i].hash = h; eqs[i].hash = h;
...@@ -251,13 +251,13 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current) ...@@ -251,13 +251,13 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
if(line == alloc_lines) if(line == alloc_lines)
{ {
/* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */ /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
if((LineRef)(LINEREF_MAX / 3) <= alloc_lines || (LineRef)(LINEREF_MAX / sizeof *cureqs) <= 2 * alloc_lines - linbuf_base || (LineRef)(LINEREF_MAX / sizeof *linbuf) <= alloc_lines - linbuf_base) if((LineRef)(LINEREF_MAX / 3) <= alloc_lines || (LineRef)(LINEREF_MAX / sizeof(*cureqs)) <= 2 * alloc_lines - linbuf_base || (LineRef)(LINEREF_MAX / sizeof(*linbuf)) <= alloc_lines - linbuf_base)
xalloc_die(); xalloc_die();
alloc_lines = 2 * alloc_lines - linbuf_base; alloc_lines = 2 * alloc_lines - linbuf_base;
cureqs = (LineRef *)xrealloc(cureqs, alloc_lines * sizeof *cureqs); cureqs = (LineRef *)xrealloc(cureqs, alloc_lines * sizeof(*cureqs));
linbuf += linbuf_base; linbuf += linbuf_base;
linbuf = (const QChar **)xrealloc(linbuf, linbuf = (const QChar **)xrealloc(linbuf,
(alloc_lines - linbuf_base) * sizeof *linbuf); (alloc_lines - linbuf_base) * sizeof(*linbuf));
linbuf -= linbuf_base; linbuf -= linbuf_base;
} }
linbuf[line] = ip; linbuf[line] = ip;
...@@ -275,12 +275,12 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current) ...@@ -275,12 +275,12 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
if(line == alloc_lines) if(line == alloc_lines)
{ {
/* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */ /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
if((LineRef)(LINEREF_MAX / 3) <= alloc_lines || (LineRef)(LINEREF_MAX / sizeof *cureqs) <= 2 * alloc_lines - linbuf_base || (LineRef)(LINEREF_MAX / sizeof *linbuf) <= alloc_lines - linbuf_base) if((LineRef)(LINEREF_MAX / 3) <= alloc_lines || (LineRef)(LINEREF_MAX / sizeof(*cureqs)) <= 2 * alloc_lines - linbuf_base || (LineRef)(LINEREF_MAX / sizeof(*linbuf)) <= alloc_lines - linbuf_base)
xalloc_die(); xalloc_die();
alloc_lines = 2 * alloc_lines - linbuf_base; alloc_lines = 2 * alloc_lines - linbuf_base;
linbuf += linbuf_base; linbuf += linbuf_base;
linbuf = (const QChar **)xrealloc(linbuf, linbuf = (const QChar **)xrealloc(linbuf,
(alloc_lines - linbuf_base) * sizeof *linbuf); (alloc_lines - linbuf_base) * sizeof(*linbuf));
linbuf -= linbuf_base; linbuf -= linbuf_base;
} }
linbuf[line] = p; linbuf[line] = p;
...@@ -443,7 +443,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[]) ...@@ -443,7 +443,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[])
LineRef l = lines++ & prefix_mask; LineRef l = lines++ & prefix_mask;
if(l == alloc_lines0) if(l == alloc_lines0)
{ {
if((LineRef)(LINEREF_MAX / (2 * sizeof *linbuf0)) <= alloc_lines0) if((LineRef)(LINEREF_MAX / (2 * sizeof(*linbuf0))) <= alloc_lines0)
xalloc_die(); xalloc_die();
alloc_lines0 *= 2; alloc_lines0 *= 2;
linbuf0 = (const QChar **)xrealloc(linbuf0, alloc_lines0 * sizeof(*linbuf0)); linbuf0 = (const QChar **)xrealloc(linbuf0, alloc_lines0 * sizeof(*linbuf0));
...@@ -460,7 +460,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[]) ...@@ -460,7 +460,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[])
middle_guess = guess_lines(lines, p0 - buffer0, p1 - filevec[1].prefix_end); middle_guess = guess_lines(lines, p0 - buffer0, p1 - filevec[1].prefix_end);
suffix_guess = guess_lines(lines, p0 - buffer0, buffer1 + n1 - p1); suffix_guess = guess_lines(lines, p0 - buffer0, buffer1 + n1 - p1);
alloc_lines1 = buffered_prefix + middle_guess + std::min(context, suffix_guess); alloc_lines1 = buffered_prefix + middle_guess + std::min(context, suffix_guess);
if(alloc_lines1 < buffered_prefix || (LineRef)(LINEREF_MAX / sizeof *linbuf1) <= alloc_lines1) if(alloc_lines1 < buffered_prefix || (LineRef)(LINEREF_MAX / sizeof(*linbuf1)) <= alloc_lines1)
xalloc_die(); xalloc_die();
linbuf1 = (const QChar **)xmalloc(alloc_lines1 * sizeof(*linbuf1)); linbuf1 = (const QChar **)xmalloc(alloc_lines1 * sizeof(*linbuf1));
...@@ -515,9 +515,9 @@ bool GnuDiff::read_files(struct file_data filevec[], bool /*pretend_binary*/) ...@@ -515,9 +515,9 @@ bool GnuDiff::read_files(struct file_data filevec[], bool /*pretend_binary*/)
find_identical_ends(filevec); find_identical_ends(filevec);
equivs_alloc = filevec[0].alloc_lines + filevec[1].alloc_lines + 1; equivs_alloc = filevec[0].alloc_lines + filevec[1].alloc_lines + 1;
if((LineRef)(LINEREF_MAX / sizeof *equivs) <= equivs_alloc) if((LineRef)(LINEREF_MAX / sizeof(*equivs)) <= equivs_alloc)
xalloc_die(); xalloc_die();
equivs = (equivclass *)xmalloc(equivs_alloc * sizeof *equivs); equivs = (equivclass *)xmalloc(equivs_alloc * sizeof(*equivs));
/* Equivalence class 0 is permanently safe for lines that were not /* Equivalence class 0 is permanently safe for lines that were not
hashed. Real equivalence classes start at 1. */ hashed. Real equivalence classes start at 1. */
equivs_index = 1; equivs_index = 1;
...@@ -528,9 +528,9 @@ bool GnuDiff::read_files(struct file_data filevec[], bool /*pretend_binary*/) ...@@ -528,9 +528,9 @@ bool GnuDiff::read_files(struct file_data filevec[], bool /*pretend_binary*/)
for(i = 9; ((LineRef)1 << i) < equivs_alloc / 3; ++i) for(i = 9; ((LineRef)1 << i) < equivs_alloc / 3; ++i)
continue; continue;
nbuckets = ((LineRef)1 << i) - prime_offset[i]; nbuckets = ((LineRef)1 << i) - prime_offset[i];
if(LINEREF_MAX / sizeof *buckets <= nbuckets) if(LINEREF_MAX / sizeof(*buckets) <= nbuckets)
xalloc_die(); xalloc_die();
buckets = (LineRef *)zalloc((nbuckets + 1) * sizeof *buckets); buckets = (LineRef *)zalloc((nbuckets + 1) * sizeof(*buckets));
buckets++; buckets++;
for(i = 0; i < 2; ++i) for(i = 0; i < 2; ++i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment