You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
330 B

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