1 #include <stdarg.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 5 void fatal(const char * format,...)6fatal(const char *format, ...) { 7 va_list args; 8 9 va_start(args, format); 10 vfprintf(stderr, format, args); 11 va_end(args); 12 fprintf(stderr, "\n"); 13 exit(1); 14 } 15 16 void * xalloc(int size)17xalloc(int size) { 18 void *p = malloc(size); 19 if (p == NULL) 20 fatal("out of memory"); 21 return p; 22 } 23