home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cnews / part01 / libc / emalloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-19  |  360 b   |  23 lines

  1. /*
  2.  * emalloc - malloc with error() called when out of space
  3.  */
  4.  
  5. #define    NULL    0
  6.  
  7. char *
  8. emalloc(amount)
  9. unsigned amount;
  10. {
  11.     register char *it;
  12.     char camount[25];        /* Enough to sprintf an unsigned. */
  13.     extern char *malloc();
  14.  
  15.     it = malloc(amount);
  16.     if (it == NULL) {
  17.         sprintf(camount, "%u", amount);
  18.         error("malloc(%s) failed", camount);
  19.     }    
  20.  
  21.     return(it);
  22. }
  23.