-- File: XFSP.mesa
-- Last Updated: October 15, 1980 4:26 PM

DIRECTORY
AltoDefs: FROM "AltoDefs" USING[PageSize],
SegmentDefs: FROM "SegmentDefs" USING[DataSegmentHandle, NewDataSegment,
DefaultXMBase, LongDataSegmentAddress],
XFSPDefs: FROM "XFSPDefs";

XFSP: PROGRAM
IMPORTS SegmentDefs
EXPORTS
XFSPDefs =
BEGIN OPEN AltoDefs, SegmentDefs;

Count: CARDINAL;
CurrentSegmentPointer: LONG POINTER ← NIL;

XAllocateHeapNode: PUBLIC PROCEDURE[size: CARDINAL] RETURNS[ptr: LONG POINTER] =
BEGIN
IF CurrentSegmentPointer=NIL OR Count+size>PageSize THEN
BEGIN
IF size>PageSize THEN ERROR;
CurrentSegmentPointer ← LongDataSegmentAddress[NewDataSegment[DefaultXMBase,1]];
Count ← 0;
END;
ptr ← CurrentSegmentPointer + Count;
Count ← Count + size;
END;

END.