aboutsummaryrefslogtreecommitdiff
path: root/sys/symtab/stfree.x
blob: 1a960fe5e485ae86c9efcf37bfc5f00d468acfaa (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
39
40
41
42
43
44
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	"symtab.h"

# STFREE -- Free storage back to the last marker.  No storage is actually
# returned to the system, rather the storage is made available for reuse
# by SYMTAB (the stacks are pruned).

procedure stfree (stp, marker)

pointer	stp			# symtab descriptor
int	marker			# magic marker

int	el
pointer	index, stab, ep, mp

begin
	index = ST_INDEX(stp)
	stab  = ST_STABP(stp)
	mp    = stab + marker
	ep    = NULL

	# Ignore requests with out of range markers.
	if (marker <= 0 || marker >= ST_STABOP(stp))
	    return

	# Descend the global (time ordered) list, unlinking each symbol until
	# the marker position is reached.

	for (el = ST_LASTSYMBOL(stp);  el > marker;  el = E_NEXTGLOB(ep)) {
	    ep = stab + el
	    Memi[index+E_THREAD(ep)] = E_NEXTHASH(ep)
	}

	# Reset the stack pointers and set the head of the global list to
	# point to the symbol immediately preceding the marker.

	ST_NSYMBOLS(stp) = M_NSYMBOLS(mp)
	ST_SBUFOP(stp)   = M_SBUFOP(mp)
	ST_STABOP(stp)   = marker

	if (ep != NULL)
	    ST_LASTSYMBOL(stp) = E_NEXTGLOB(ep)
end