home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / PFC / SRC / MEMGIVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-21  |  1.6 KB  |  61 lines

  1. #include "compiler.h"
  2.  
  3.  
  4. /* (c) 1985, Phoenix Computer Products Corp. and Novum Organum, Inc. */
  5. /***
  6. * name :    memgive  - allocate space from heap.
  7. *            memgivetrap - allocate, but don't longjmp on out of space
  8. *        memtake    - free memory allocated with memgive() and givecopy()
  9. *
  10. * synopsis:    p = memgive(siz)
  11. *                  p = memgivetrap(siz)
  12. *        siz     size of cell being allocated.
  13. *        memtake(p)
  14. *        p    pointer to allocated memory space.
  15. *
  16. * description:    these calls may seem redundant, but it makes the library
  17. *        functions more implementation independent.  for example,
  18. *        my libraries run on a system call PORT, which is a multi-object
  19. *        message passing distributed system.  there are special functions
  20. *        which must be called when getting and freeing.  however, they
  21. *        are not called malloc() and free(), but _alloc() and _free().
  22. *        in addition, there are other functions named malloc() and
  23. *        free(), so I can't dummy up free, i.e. free(p){_free(p);}.
  24. *        however, since all my functions call memgive() and memtake()
  25. *        I just dummy them up, i.e. memtake(p){_free(p);}, in this
  26. *        file and everything transports over with no problem.
  27. *
  28. * returns:    
  29. *
  30. * (C) novum organum, inc. 1985
  31. *
  32. ***/
  33. #include "cptpdf.h"
  34.  
  35. char *memgive (siz) 
  36.     int    siz;
  37. {
  38.     char *space;
  39.  
  40.     if    (!(space = CALLOC (1, siz)))  /* if not allocated do a leave */
  41.         sylongjmp(SE_OUTOFHEAP);
  42.  
  43.     return  (space);
  44. }
  45.  
  46. char *memgivetrap (siz) 
  47.     int    siz;
  48. {
  49.     char *space;
  50.  
  51.     space = CALLOC (1, siz);
  52.  
  53.     return  (space);
  54. }
  55.  
  56. memtake (allocd_mem)
  57.     char    *allocd_mem;
  58. {
  59.     FREE (allocd_mem);
  60. }
  61.