6 /* If memory allocation fails, bail out */
7 void *factorvm::safe_malloc(size_t size)
9 void *ptr = malloc(size);
10 if(!ptr) fatal_error("Out of memory in safe_malloc", 0);
14 void *safe_malloc(size_t size)
16 return vm->safe_malloc(size);
19 vm_char *factorvm::safe_strdup(const vm_char *str)
21 vm_char *ptr = STRDUP(str);
22 if(!ptr) fatal_error("Out of memory in safe_strdup", 0);
26 vm_char *safe_strdup(const vm_char *str)
28 return vm->safe_strdup(str);
31 /* We don't use printf directly, because format directives are not portable.
32 Instead we define the common cases here. */
43 void factorvm::print_string(const char *str)
48 void print_string(const char *str)
50 return vm->print_string(str);
53 void factorvm::print_cell(cell x)
55 printf(CELL_FORMAT,x);
58 void print_cell(cell x)
60 return vm->print_cell(x);
63 void factorvm::print_cell_hex(cell x)
65 printf(CELL_HEX_FORMAT,x);
68 void print_cell_hex(cell x)
70 return vm->print_cell_hex(x);
73 void factorvm::print_cell_hex_pad(cell x)
75 printf(CELL_HEX_PAD_FORMAT,x);
78 void print_cell_hex_pad(cell x)
80 return vm->print_cell_hex_pad(x);
83 void factorvm::print_fixnum(fixnum x)
85 printf(FIXNUM_FORMAT,x);
88 void print_fixnum(fixnum x)
90 return vm->print_fixnum(x);
93 cell factorvm::read_cell_hex()
96 if(scanf(CELL_HEX_FORMAT,&cell) < 0) exit(1);
102 return vm->read_cell_hex();