Skip to content

Commit

Permalink
Some compilers seem to like having the sizeof in front when mallocing
Browse files Browse the repository at this point in the history
  • Loading branch information
daschaich committed Jan 6, 2018
1 parent a1cda29 commit e2d120b
Show file tree
Hide file tree
Showing 28 changed files with 182 additions and 177 deletions.
4 changes: 2 additions & 2 deletions 4d_Q16/correlators/konishi.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ void correlator_r() {
Real one_ov_block = 1.0 / (Real)Nblock, blockNorm = 1.0 / (Real)Nmeas;
Real std_norm = 1.0 / (Real)(Nblock * (Nblock - 1.0));
Real ave, err, tr;
Kcorrs **corr = malloc(Nblock * sizeof(**corr));
Kcorrs **corr = malloc(sizeof **corr * Nblock);

// Set up Nblock Konishi and SUGRA correlators
// Will be initialized within block loop below
for (block = 0; block < Nblock; block++)
corr[block] = malloc(total_r * sizeof(Kcorrs));
corr[block] = malloc(sizeof Kcorrs * total_r);

// Compute correlators for each block
for (block = 0; block < Nblock; block++) {
Expand Down
16 changes: 8 additions & 8 deletions 4d_Q16/correlators/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int readin(int prompt) {
strcpy(cfg[j], par_buf.cfg[j]);

// Allocate Konishi and SUGRA operators now that we know tot_meas
ops = malloc(tot_meas * sizeof(**ops));
ops = malloc(sizeof **ops * tot_meas);
for (j = 0; j < tot_meas; j++)
FIELD_ALLOC(ops[j], Kops);
size = (Real)(tot_meas * sizeof(Kops)) * sites_on_node;
Expand All @@ -232,19 +232,19 @@ int readin(int prompt) {
// These two arrays only need to be of size total_r <= MAX_pts
// but allocate MAX_pts memory for simplicity
// Initialize to nonsense; can be used to check that they have been reset
lookup = malloc(MAX_pts * sizeof(*lookup));
norm = malloc(MAX_pts * sizeof(*norm));
lookup = malloc(sizeof *lookup * MAX_pts);
norm = malloc(sizeof *norm * MAX_pts);
for (j = 0; j < MAX_pts; j++) {
lookup[j] = -1.0;
norm[j] = -1.0;
}

// Allocate arrays to be used by LAPACK in unit.c
ipiv = malloc(NCOL * sizeof(*ipiv));
store = malloc(2 * NCOL * NCOL * sizeof(*store));
work = malloc(4 * NCOL * sizeof(*work));
Rwork = malloc((3 * NCOL - 2) * sizeof(*Rwork));
eigs = malloc(NCOL * sizeof(*eigs));
ipiv = malloc(sizeof *ipiv * NCOL);
store = malloc(sizeof *store * 2 * NCOL * NCOL);
work = malloc(sizeof *work * 4 * NCOL);
Rwork = malloc(sizeof *Rwork * (3 * NCOL - 2));
eigs = malloc(sizeof *eigs * NCOL);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion 4d_Q16/correlators/utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Real A4map(x_in, y_in, z_in, t_in) {
int count_points(Real MAX_r) {
int total = 0, this, j, x_dist, y_dist, z_dist, t_dist;
int y_start, z_start, t_start;
int *count = malloc(MAX_pts * sizeof(*count));
int *count = malloc(sizeof *count * MAX_pts);
Real tr;

for (x_dist = 0; x_dist <= MAX_X; x_dist++) {
Expand Down
Loading

0 comments on commit e2d120b

Please sign in to comment.