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. */
38 void factorvm::print_string(const char *str)
43 void print_string(const char *str)
45 return vm->print_string(str);
48 void factorvm::print_cell(cell x)
50 printf(CELL_FORMAT,x);
53 void factorvm::print_cell_hex(cell x)
55 printf(CELL_HEX_FORMAT,x);
58 void factorvm::print_cell_hex_pad(cell x)
60 printf(CELL_HEX_PAD_FORMAT,x);
63 void factorvm::print_fixnum(fixnum x)
65 printf(FIXNUM_FORMAT,x);
68 cell factorvm::read_cell_hex()
71 if(scanf(CELL_HEX_FORMAT,&cell) < 0) exit(1);