home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.orig.lzh / libc / emalloc.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  403b  |  26 lines

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