home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 5.ddi / MWHC.005 / K3 < prev    next >
Encoding:
Text File  |  1992-12-09  |  1.7 KB  |  43 lines

  1. { (C) Copyright  1986-1992 MetaWare Incorporated;  Santa Cruz, CA 95060. }
  2.  
  3. pragma C_include('Implement.pf');
  4. { Release(H) causes any item in the heap allocated since the
  5.   call to Mark(H) to be freed.
  6.   Typical usage:
  7.     var H:HeapMark;
  8.     ...
  9.     Mark(H);
  10.     new(...); new(...); new(...);
  11.     ... -- perhaps more news ...
  12.     Release(H);
  13.         -- release all storage allocated since the mark.
  14.   If the HeapMark H passed into Release is not valid,
  15.   Release ignores the request.
  16.   
  17.   Release disposes memory in all heaps except heap #0.
  18.   Release operates by examining each element in all heaps.
  19.   Any such element allocated since the Mark was made is freed.
  20.   Thus Release is not a "cheap" pointer copy as some may expect; 
  21.   however, it works on all systems we support.
  22.   
  23.   In the phrase "since the Mark was made" we refer to a notion of time.
  24.   "Time" is maintained by a global counter.  Each time a Mark is made,
  25.   the counter is incremented and its value placed in the Mark structure.
  26.   Upon Release, the global counter is set to the value stored, minus one;
  27.   the global time is set back.
  28.   
  29. }
  30. package Mark_release type HeapMark;
  31.    pragma Routine_aliasing_convention(Implement.RTE_aliasing);
  32.    type HeapMark = record
  33.       Time_of_mark: Cardinal;
  34.       Private: Cardinal;    -- Used as a consistency check against trash.
  35.       end;
  36.    procedure Mark(var H: HeapMark);        external;
  37.    procedure Release(var H: HeapMark);        external;
  38.    -- VS Pascal mark/release for 8086 16-bit pointers.
  39.    -- We store only the Time_of_mark and give up the Private protection.
  40.    procedure VSMark(var C: Cardinal);        external;
  41.    procedure VSRelease(var C: Cardinal);    external;
  42.    end;
  43.