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

include	<syserr.h>

# MFREE -- Free a previously allocated buffer.  If the buffer has already been
# returned (NULL pointer), ignore the request.  Once the buffer has been
# returned, the old pointer value is of not useful (and invalid), so set it
# to NULL.

procedure mfree (ptr, dtype)

pointer	ptr
int	fwa, dtype, status
int	mgtfwa()
errchk	mgtfwa

begin
	if (ptr != NULL) {
	    fwa = mgtfwa (ptr, dtype)

	    call zmfree (fwa, status)
	    if (status == ERR)
		call sys_panic (SYS_MCORRUPTED, "Memory has been corrupted")

	    ptr = NULL
	}
end