home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 4.ddi / LIB / SRC / MRKRLS.PF < prev    next >
Encoding:
Text File  |  1990-12-16  |  1.6 KB  |  41 lines

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