-- File: DBHeapStorageImpl.mesa
-- Contents: to enable counting of allocs and de-allocs

  DIRECTORY
    DBHeapStorage,
    Storage;

DBHeapStorageImpl: PROGRAM
  IMPORTS
    Storage
  EXPORTS
    DBHeapStorage
  = BEGIN

  allocCount: INT ← 0;
  flag: BOOL← FALSE;
  sizeCount: INT ← 0;

  Node: PUBLIC PROC [size: CARDINAL] RETURNS [POINTER] =  {
    temp: POINTER ←Storage.Node[size];
    allocCount← allocCount+1;
    IF size=5 THEN flag← TRUE; -- just to give place to set breakpoint
    sizeCount← sizeCount + LOOPHOLE[temp-1, POINTER TO CARDINAL]↑;
    RETURN[temp] };

  Free: PUBLIC PROC [object: POINTER] =  {
    allocCount← allocCount-1;
    sizeCount← sizeCount - LOOPHOLE[object-1, POINTER TO CARDINAL]↑;
    Storage.Free[object] };

END.--DBHeapStorage


CHANGE LOG