xmalloc.c 536 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * UAE - The Un*x Amiga Emulator
  3. *
  4. * Various stuff missing in some OSes.
  5. *
  6. * Copyright 1997 Bernd Schmidt
  7. */
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "sysdep.h"
  12. void *xmalloc(size_t n)
  13. {
  14. void *a = malloc (n);
  15. if (a == NULL) {
  16. fprintf (stderr, "virtual memory exhausted\n");
  17. abort ();
  18. }
  19. return a;
  20. }
  21. void *xcalloc (size_t n, size_t size)
  22. {
  23. void *a = calloc (n, size);
  24. if (a == NULL) {
  25. fprintf (stderr, "virtual memory exhausted\n");
  26. abort ();
  27. }
  28. return a;
  29. }