comparison gen.c @ 792:724bbec47f86

Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
author Michael Pavone <pavone@retrodev.com>
date Sat, 25 Jul 2015 18:22:07 -0700
parents c8fefa140c80
children a7774fc2de4b
comparison
equal deleted inserted replaced
791:60686f8d5e48 792:724bbec47f86
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include "gen.h" 3 #include "gen.h"
4 #include "mem.h" 4 #include "mem.h"
5 #include "util.h"
5 6
6 void init_code_info(code_info *code) 7 void init_code_info(code_info *code)
7 { 8 {
8 size_t size = CODE_ALLOC_SIZE; 9 size_t size = CODE_ALLOC_SIZE;
9 code->cur = alloc_code(&size); 10 code->cur = alloc_code(&size);
10 if (!code->cur) { 11 if (!code->cur) {
11 fputs("Failed to allocate memory for generated code\n", stderr); 12 fatal_error("Failed to allocate memory for generated code\n");
12 exit(1);
13 } 13 }
14 code->last = code->cur + size/sizeof(code_word) - RESERVE_WORDS; 14 code->last = code->cur + size/sizeof(code_word) - RESERVE_WORDS;
15 } 15 }