Research V7 development
[unix-history] / usr / src / cmd / struct / 2.main.c
CommitLineData
2a70a0a1
BB
1#include <stdio.h>
2#include "def.h"
3#include "2.def.h"
4
5VERT *after;
6int *ntobef, *ntoaft;
7build()
8 {
9 VERT v, *dom, *head;
10 int type;
11 struct list **inarc;
12 dfs(START);
13 if (routerr) return;
14 for (v = 0; v < nodenum; ++v)
15 {
16 type = NTYPE(v);
17 if (type == LOOPVX || type == DOVX)
18 FATH(ARC(v,0)) = v;
19 }
20
21 head = challoc(sizeof(*head) * nodenum);
22 if (progress) fprintf(stderr," gethead:\n");
23 gethead(head); /* sets head[v] to ITERVX heading smallest loop containing v or UNDEFINED */
24
25 if (routerr) return;
26 inarc = challoc(nodenum * sizeof(*inarc));
27 if (progress) fprintf(stderr," getinarc:\n");
28 getinarc(inarc,head); /* sets inarc[v] to list of forward arcs entering v */
29
30 dom = challoc(nodenum * sizeof(*dom));
31 if (progress) fprintf(stderr," getdom:\n");
32 getdom(inarc,dom); /* sets dom[v] to immediate dominator of v or UNDEFINED */
33 if (routerr) return;
34 if (progress) fprintf(stderr," gettree:\n");
35 gettree(inarc, dom, head);
36 if (routerr) return;
37
38 chfree(head, nodenum * sizeof(*head)); head = 0;
39 chfree(dom,nodenum * sizeof(*dom)); dom = 0;
40 for (v = 0; v < nodenum; ++v)
41 {
42 freelst(inarc[v]);
43 inarc[v] = 0;
44 }
45 chfree(inarc,sizeof(*inarc) * nodenum); inarc = 0;
46 chfree(ntoaft,sizeof(*ntoaft) * nodenum); ntoaft = 0;
47 chfree(ntobef,sizeof(*ntobef) * nodenum); ntobef = 0;
48 chfree(after, sizeof(*after) * accessnum); after = 0;
49 }