-- Copyright (C) 1981, 1984  by Xerox Corporation. All rights reserved. 
-- IFSFileOpsC.mesa

-- HGM, 15-Sep-85  8:53:54
-- Last edited by Levin, 28-Jan-81 17:42:06

DIRECTORY
  Heap USING [systemZone],
  IFSFilePrivate USING [IORequest, IORequestBlock];

IFSFileOpsC: MONITOR IMPORTS Heap EXPORTS IFSFilePrivate =

  BEGIN OPEN IFSFilePrivate;

  -- Global Variables --

  freeList: IORequest;

  -- Procedures exported to IFSFilePrivate --

  InitializeFreeList: PUBLIC PROCEDURE = {freeList ← NIL};

  FinalizeFreeList: PUBLIC PROCEDURE =
    BEGIN
    UNTIL freeList = NIL DO
      request: IORequest ← freeList;
      freeList ← freeList.link;
      Heap.systemZone.FREE[@request];
      ENDLOOP;
    END;

  GetIORequestBlock: PUBLIC ENTRY PROCEDURE RETURNS [request: IORequest] =
    BEGIN
    IF freeList ~= NIL THEN {request ← freeList; freeList ← request.link}
    ELSE request ← Heap.systemZone.NEW[IORequestBlock];
    END;

  FreeIORequestBlock: PUBLIC ENTRY PROCEDURE [request: IORequest] =
    BEGIN request.link ← freeList; freeList ← request; END;

  END.