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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include "symtab.h"
define SZ_BLOCK 2048
# STSAVE -- Save the symbol table in an external binary file in a machine
# independent format. This works provided only integer and character data
# is stored in the symbol table.
procedure stsave (stp, fd)
pointer stp # symtab descriptor
int fd # output file
int nelem
int ip, itop
errchk miiwritei, miiwritec
begin
call miiwritei (fd, Memi[stp], LEN_SYMTAB)
call miiwritei (fd, Memi[ST_INDEX(stp)], ST_INDEXLEN(stp))
# Since the symbol table can be very large, write it out in chunks
# of a reasonable size to avoid allocating large buffers.
itop = ST_STABP(stp) + ST_STABLEN(stp)
for (ip=ST_STABP(stp); ip < itop; ip=ip+nelem) {
nelem = min (SZ_BLOCK, itop - ip)
call miiwritei (fd, Memi[ip], nelem)
}
# Ditto for the string buffer.
itop = ST_SBUFP(stp) + ST_SBUFLEN(stp)
for (ip=ST_SBUFP(stp); ip < itop; ip=ip+nelem) {
nelem = min (SZ_BLOCK, itop - ip)
call miiwritec (fd, Memc[ip], nelem)
}
end
|