aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fmkpbbuf.x
blob: ee891949b21dbbc18e52d9fec2bc701b14b99e16 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

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

# FMKPBBUF -- Make the push back buffer.  Called when the first attempt is
# made to push data back into an input stream.

procedure fmkpbbuf (fd)

int	fd
int	buflen
pointer	bp
errchk	malloc
include	<fio.com>

begin
	fp = fiodes[fd]
	if (bufptr[fd] == NULL)
	    call fmkbfs (fd)

	buflen = FPBBUFSIZE(fp)
	if (buflen <= 0) {
	    buflen = SZ_PBBUF
	    FPBBUFSIZE(fp) = buflen
	}

	call malloc (bp, buflen, TY_CHAR)

	FPBBUF(fp) = bp
	FPBTOP(fp) = bp + buflen
	FPBIOP(fp) = bp
	FPBSP(fp) = (FPBTOP(fp) - 1) / SZ_INT + 1
end