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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <ctype.h>
# MEMCHK -- Scan the mem.log output produced by the debug version of MEMIO
# (this must be sorted first) and check for memory which is allocated but
# never freed.
procedure t_memchk()
int fd, ip
bool passall, mark
int addr, retaddr, seqno, action, class
int old_addr, old_seqno, old_action
char lbuf[SZ_LINE], old_lbuf[SZ_LINE]
char descr[SZ_LINE], old_descr[SZ_LINE]
char tokbuf[SZ_FNAME], fname[SZ_FNAME]
bool clgetb()
int open(), getline(), nscan(), gctol()
define print_ 91
begin
call clgstr ("fname", fname, SZ_FNAME)
fd = open (fname, READ_ONLY, TEXT_FILE)
passall = clgetb ("passall")
old_addr = 0
old_action = 0
while (getline (fd, lbuf) != EOF) {
# Scan next line.
call sscan (lbuf)
call gargwrd (tokbuf, SZ_FNAME)
ip = 1; ip = gctol (tokbuf, ip, addr, 16)
call gargi (seqno)
call gargwrd (tokbuf, SZ_FNAME)
ip = 1; ip = gctol (tokbuf, ip, retaddr, 16)
call gargwrd (tokbuf, SZ_FNAME)
action = tokbuf[1]
call gargi (class)
call gargstr (descr, SZ_LINE)
if (nscan() < 4) {
if (passall)
call putline (STDOUT, lbuf)
next
}
if (addr != old_addr) {
# Starting a log for a new buffer address.
if (old_lbuf[1] != EOS) {
if (IS_ALPHA(old_action) && old_action != 'F') {
ip = 1
while (old_lbuf[ip] != '\n' && old_lbuf[ip] != EOS)
ip = ip + 1
old_lbuf[ip] = EOS
call printf ("%s %70t####\n")
call pargstr (old_lbuf)
} else if (passall)
call putline (STDOUT, old_lbuf)
}
} else {
# Verify operation on a particular buffer address.
if (old_lbuf[1] != EOS && passall)
call putline (STDOUT, old_lbuf)
mark = false
if (IS_ALPHA(action) && class == 1)
switch (old_action) {
case 'A', 'R':
if (action != 'R' && action != 'F')
mark = true
case 'F':
if (action != 'A')
mark = true
}
if (mark) {
ip = 1
while (lbuf[ip] != '\n' && lbuf[ip] != EOS)
ip = ip + 1
lbuf[ip] = EOS
call printf ("%s %70t####\n")
call pargstr (lbuf)
lbuf[1] = EOS
}
}
old_addr = addr
old_seqno = seqno
old_action = action
call strcpy (descr, old_descr, SZ_LINE)
call strcpy (lbuf, old_lbuf, SZ_LINE)
}
if (old_lbuf[1] != EOS && passall)
call putline (STDOUT, old_lbuf)
end
|