include	clib.inc
include	stdio.inc
include	malloc.inc

PPROC	_freebuf, FP:DPTR
	MLES	bx,FP
	mov	ax,es:[bx.iob_flag]
	mov	dx,ax
	and	ax,_IOREAD or _IOWRT or _IORW
	jz	_freebuf_00
	and	dx,_IOMYBUF
	jz	_freebuf_00
	MPUSH	word ptr es:[bx.iob_base+2]
	push	word ptr es:[bx.iob_base]
	call	free
	MLES	bx,FP
	xor	ax,ax
	mov	word ptr es:[bx.iob_bp],ax
	mov	word ptr es:[bx.iob_bp+2],ax
	mov	word ptr es:[bx.iob_base],ax
	mov	word ptr es:[bx.iob_base+2],ax
	mov	es:[bx.iob_flag],ax
	mov	es:[bx.iob_bufsize],ax
	mov	es:[bx.iob_cnt],ax
    _freebuf_00:
	ret
PEND	_freebuf

	END
