home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / conf2 / part02 / confalloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  602 b   |  43 lines

  1. #include "conf.h"
  2.  
  3. /*
  4.  *    memory managment stuff.
  5.  */
  6.  
  7. char *
  8. mymalloc(size)
  9. unsigned size;
  10. {
  11.     char *p;
  12.  
  13.     if ((p = malloc(size)) == NULL)
  14.     {
  15.     (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  16.     nice_exit(-1);
  17.     }
  18.  
  19.     return p;
  20. }
  21.  
  22. char *
  23. myrealloc(p, size)
  24. char *p;
  25. unsigned size;
  26. {
  27.     if (p == NULL)
  28.     {
  29.     if ((p = malloc(size)) == NULL)
  30.     {
  31.         (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  32.         nice_exit(-1);
  33.     }
  34.     }
  35.     else if ((p = realloc(p, size)) == NULL)
  36.     {
  37.     (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  38.     nice_exit(-1);
  39.     }
  40.  
  41.     return p;
  42. }
  43.