aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/frmbfs.x
blob: ec1df5e7bf07c438848011b6b1f323e6d6c18da4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<config.h>
include	<fio.h>

# FRMBFS -- Return file buffer.  Called by FSET to change the buffer size,
# and by FRTNFD when a file is closed.

procedure frmbfs (fd)

int	fd			# file descriptor

long	offset
errchk	mfree, flush
include	<fio.com>

begin
	fp = fiodes[fd]
	if (bufptr[fd] == NULL)
	    return
	else
	    call fcanpb (fd)

	# Note file offset, return buffer and initialize i/o pointers,
	# restore seek offset (which depends on buffer pointer, buf offset).

	offset = LNOTE(fd)
	call mfree (bufptr[fd], TY_CHAR)
	call mfree (FPBBUF(fp), TY_CHAR)

	bufptr[fd] = NULL
	boffset[fd] = NULL
	buftop[fd] = NULL
	itop[fd] = NULL
	otop[fd] = NULL

	LSEEK (fd, offset)
end