|
|
1.1 root 1: /*
2: * Symbol table management.
3: */
4: #ifdef vax
5: #include "INC$LIB:cc1.h"
6: #else
7: #include "cc1.h"
8: #endif
9:
10: /*
11: * Lookup a global (or static external)
12: * identifier in the symbol table. Return a pointer
13: * to the symbol structure. If it is not there add
14: * it. This table exists only to save space and to make
15: * the TREE nodes all the same size.
16: */
17: SYM *
18: gidpool(id)
19: char *id;
20: {
21: register SYM *sp;
22: register char *p;
23: register int c;
24: register int h;
25:
26: h = 0;
27: p = id;
28: while ((c = *p++) != '\0')
29: h += c;
30: h &= SHMASK;
31: sp = hash1[h];
32: while (sp != NULL) {
33: if (strcmp(id, sp->s_id) == 0)
34: return (sp);
35: sp = sp->s_fp;
36: }
37: if ((sp=(SYM *)malloc(sizeof(SYM)+strlen(id)+1)) == NULL)
38: cnomem("gidpool");
39: sp->s_fp = hash1[h];
40: hash1[h] = sp;
41: strcpy(sp->s_id, id);
42: return (sp);
43: }
44:
45: #if OVERLAID
46: /*
47: * Free all symbols.
48: */
49: freegsym()
50: {
51: register SYM *sp1, *sp2;
52: register int i;
53:
54: for (i=0; i<NSHASH; ++i) {
55: sp1 = hash1[i];
56: while (sp1 != NULL) {
57: sp2 = sp1->s_fp;
58: free((char *) sp1);
59: sp1 = sp2;
60: }
61: hash1[i] = NULL;
62: }
63: }
64: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.