home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part03 / mem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-14  |  822 b   |  51 lines

  1. /*
  2. **    Memory management module.
  3. */
  4.  
  5. static    char
  6. rcs_id[] = "$Header: /mip/zs/src/sys/cake/RCS/mem.c,v 1.15 87/10/05 20:15:10 zs Exp $";
  7.  
  8. #include    "cake.h"
  9.  
  10. /*
  11. **    Allocate space if possible. In the future it may record
  12. **    all pointers returned, so that old can do some checks.
  13. */
  14.  
  15. Cast
  16. newmem(size)
  17. int    size;
  18. {
  19.     reg    char    *space;
  20.  
  21.     if ((space = malloc((unsigned) size)) == NULL)
  22.     {
  23.         fprintf(stderr, "cake system error: no more malloc\n");
  24.         exit_cake(FALSE);
  25.     }
  26.  
  27. #ifdef    EXTRACHECK
  28.     if (((int) space & 03) != 0)
  29.     {
  30.         fprintf(stderr, "cake system error: malloc not aligned\n");
  31.         exit_cake(FALSE);
  32.     }
  33. #endif
  34.  
  35.     return (Cast) space;
  36. }
  37.  
  38. /*
  39. **    Return some storage to the free list. This storage must
  40. **    have been obtained from new and malloc.
  41. */
  42.  
  43. /*ARGSUSED*/
  44. oldmem(ptr)
  45. Cast    ptr;
  46. {
  47. #ifdef    MEMUSED
  48.     free((char *) ptr);
  49. #endif
  50. }
  51.