home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / stdlib / xmalloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-01  |  384 b   |  20 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <stdlib.h>
  3. #include <io.h>
  4. #include <unistd.h>
  5.  
  6. static char msg[] = "Fatal: malloc returned NULL\r\n";
  7.  
  8. void * xmalloc(size_t _sz);
  9. void *
  10. xmalloc(size_t _sz)
  11. {
  12.   void *rv = malloc(_sz?_sz:1);
  13.   if (rv == 0)
  14.   {
  15.     _write(STDERR_FILENO, msg, sizeof(msg)-1);
  16.     _exit(1);
  17.   }
  18.   return rv;
  19. }
  20.