When an error occurs, exit program with non-zero exit code.
Chris Pressey
4 years ago
58 | 58 | v1.0: circa Jun 2018 |
59 | 59 | handle trampoline at leftmost/topmost edges |
60 | 60 | (thanks to https://github.com/serprex for this fix!) |
61 | exit with non-zero error code on error | |
61 | 62 | |
62 | 63 | v0.94: Sep 2004, Chris Pressey |
63 | 64 | cleanup only, no functional changes |
167 | 168 | if ((pg == NULL) || (pgbuf == NULL)) |
168 | 169 | { |
169 | 170 | printf ("Error: can't allocate %d bytes of memory.\n", LINEWIDTH * PAGEHEIGHT); |
170 | exit(0); | |
171 | exit (1); | |
171 | 172 | } |
172 | 173 | memset(pg, ' ', LINEWIDTH * PAGEHEIGHT); |
173 | 174 | memset(pgbuf, ' ', LINEWIDTH * PAGEHEIGHT); |
178 | 179 | if (prof[i] == NULL) |
179 | 180 | { |
180 | 181 | printf ("Error: can't allocate %lu bytes of memory.\n", (long)(LINEWIDTH * PAGEHEIGHT * sizeof(long int))); |
181 | exit(0); | |
182 | exit (1); | |
182 | 183 | } |
183 | 184 | memset(prof[i], 0, LINEWIDTH * PAGEHEIGHT * sizeof(long int)); |
184 | 185 | } |
186 | 187 | if (argc < 2) |
187 | 188 | { |
188 | 189 | printf ("USAGE: befprof [-l] [-q] [-i] [-n count] [-r input] [-w foo.map] foo.bf\n"); |
189 | exit (0); | |
190 | exit (1); | |
190 | 191 | } |
191 | 192 | |
192 | 193 | strcpy(filename, argv[argc - 1]); |
243 | 244 | } else |
244 | 245 | { |
245 | 246 | printf ("Error: couldn't open '%s' for input.\n", filename); |
246 | exit (0); | |
247 | exit (1); | |
247 | 248 | } |
248 | 249 | |
249 | 250 | if (!(fp = fopen (mapfilename, "w"))) |
250 | 251 | { |
251 | 252 | printf ("Error : couldn't open '%s' for output.\n", mapfilename); |
252 | exit (0); | |
253 | exit (1); | |
253 | 254 | } |
254 | 255 | |
255 | 256 | while (rep <= reps) |
268 | 269 | if (!(fi = fopen (argv[ia], "r"))) |
269 | 270 | { |
270 | 271 | printf ("Error : couldn't open '%s' for input.\n", argv[ia]); |
271 | exit (0); | |
272 | exit (1); | |
272 | 273 | } |
273 | 274 | } |
274 | 275 |