2 static char rcsid[] = "$Id: salloc.c,v 0.5 1994/06/24 13:28:05 ceriel Exp $";
15 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
16 * See the copyright notice in the ACK home directory, in the file "Copyright".
18 * Author: Hans van Staveren
22 * Package for string allocation and garbage collection.
23 * Call salloc(size) to get room for string.
24 * Every now and then call garbage_collect() from toplevel.
34 string myalloc(size) {
37 p = (string) malloc((unsigned)size);
39 fatal("Out of memory");
51 for (i=nnstab;i<nstab;i++)
60 fatal("String table overflow");
61 p = myalloc(size+1); /* extra room for terminating zero */
66 compar(p1,p2) char **p1,**p2; {
80 register char **fillp,**scanp;
81 char used[MAXSTAB]; /* could be bitarray */
85 qsort((char *)stab,nstab,sizeof (char *),compar);
88 for(emlp=emlines;emlp<emlines+nemlines;emlp++)
89 chkstr(emlp->em_soper,used);
90 for (tp= fakestack;tp<&fakestack[stackheight];tp++) {
93 tdp = &tokens[tp->t_token];
94 for (i=0;i<TOKENSIZE;i++)
95 if (tdp->t_type[i] == EV_ADDR)
96 chkstr(tp->t_att[i].aa.ea_str,used);
98 for (rp= machregs+1; rp<machregs+NREGS; rp++) {
100 assert(tp->t_token != -1);
101 tdp= &tokens[tp->t_token];
102 for (i=0;i<TOKENSIZE;i++)
103 if (tdp->t_type[i] == EV_ADDR)
104 chkstr(tp->t_att[i].aa.ea_str,used);
106 for (i=0;i<nstab;i++)
112 for (scanp=stab;scanp<stab+nstab;scanp++)
118 chkstr(str,used) string str; char used[]; {
119 register low,middle,high;
123 middle= (low+high)>>1;
124 if (str==stab[middle]) {
128 if (str<stab[middle])
134 if (str==stab[low]) {