Skip to content

Commit 5054ab8

Browse files
committed
Fix allocation linter error
1 parent 533927d commit 5054ab8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mcstas-comps/examples/Tests_optics/Test_Monochromator_bent_complex/Test_Monochromator_bent_complex.instr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,24 @@ double y_rots[92] = {
163163
if (use_single_plane){
164164

165165
input_planes = malloc(5*sizeof(char));
166+
if (!input_planes){
167+
printf("\nError Mallocing input planes! Exiting \n");
168+
exit(1);
169+
}
166170
input_planes = "Si111";
167171
} else {
168-
printf("Running input planes\n");
169172
input_planes = malloc(92*5*sizeof(char) + 92*sizeof(char));
170-
printf("Malloc worked!\n");
173+
if (!input_planes){
174+
printf("\nError Mallocing input planes! Exiting \n");
175+
exit(1);
176+
}
171177
strcpy(input_planes, "Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
172178
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
173179
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
174180
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
175181
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
176182
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;"
177183
"Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111;Si111");
178-
printf("\nAfter input planes\n");
179184
}
180185

181186

0 commit comments

Comments
 (0)