3 * Facility: m4 macro processor
10 extern char *strsave();
13 * hash - compute hash value using the proverbial
14 * hashing function. Taken from K&R.
22 return (h
% HASHSIZE
);
26 * lookup - find name in the hash table
34 for (p
= hashtab
[hash(name
)]; p
!= nil
; p
= p
->nxtptr
)
35 if (strcmp(name
, p
->name
) == 0)
41 * addent - hash and create an entry in the hash
42 * table. The new entry is added in front
52 if ((p
= (ndptr
) malloc(sizeof(struct ndblock
))) != NULL
) {
53 p
->nxtptr
= hashtab
[h
];
55 p
->name
= strsave(name
);
58 error("m4: no more memory.");
63 * remhash - remove an entry from the hashtable
71 register ndptr xp
, tp
, mp
;
77 if (strcmp(mp
->name
, name
) == 0) {
99 * freent - free a hashtable information block
105 if (!(p
->type
& STATIC
)) {