Skip to content

Commit 1b6d18c

Browse files
committed
Back to malloc/free - but postpone free until end of function scope...
1 parent a1fb0d4 commit 1b6d18c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mcstas-comps/samples/Isotropic_Sqw.comp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ struct Sqw_Data_struct *Sqw_readfile(
13811381
Sqw->compname, file, Sqw->type=='c' ? "coh" : "inc");
13821382
);
13831383

1384-
double w_file2full[w_bins]; /* lookup table for fast file -> Sqw_full allocation */
1384+
double *w_file2full = malloc(w_bins*sizeof(double)); /* lookup table for fast file -> Sqw_full allocation */
13851385

13861386
for (index_w=0; index_w < w_bins; w_file2full[index_w++]=0);
13871387

@@ -1422,7 +1422,7 @@ struct Sqw_Data_struct *Sqw_readfile(
14221422
w_file2full[index_w] = index_w_file;
14231423
}
14241424

1425-
double q_file2full[q_bins];
1425+
double *q_file2full=malloc(q_bins*sizeof(double));
14261426
for (index_q=0; index_q < q_bins; q_file2full[index_q++]=0);
14271427

14281428
for (index_q=0; index_q < q_bins; index_q++) {
@@ -1932,7 +1932,8 @@ struct Sqw_Data_struct *Sqw_readfile(
19321932
Sqw->compname, Sqw->lookup_length);
19331933
);
19341934
}
1935-
1935+
free(w_file2full);
1936+
free(q_file2full);
19361937
return(Sqw_Data);
19371938
} /* end Sqw_readfile */
19381939

0 commit comments

Comments
 (0)