// MDout -- output buffering for MicroD
// last edited July 20, 1978  9:24 AM

external	// defined here
[	AllocOut	// (zone, len)
	WriteOut	// ()
	FreeOut	// (zone)
	// statics -- clients manipulate these directly
	@OutBuf
	@OutPtr
	@OutEnd
]

external
[		// MDmain
	@MBS
		// O.S.
	Allocate; Free
	WriteBlock
]


static
[	@OutBuf
	@OutPtr
	@OutEnd
]


let AllocOut(zone, len) be
[	OutBuf = Allocate(zone, len)
	OutPtr = OutBuf
	OutEnd = OutBuf+len
]

let WriteOut() be
[	if OutPtr ne OutBuf then WriteBlock(MBS, OutBuf, OutPtr-OutBuf)
	OutPtr = OutBuf
]

let FreeOut(zone) be
	Free(zone, OutBuf, OutEnd-OutBuf)