Esempio n. 1
0
void
marktree(Node *n)
{

	if(n == 0)
		return;

	marktree(n->left);
	marktree(n->right);

	n->ngc.gcmark = 1;
	if(n->op != OCONST)
		return;

	switch(n->type) {
	case TSTRING:
		n->nstore.u0.sstring->sgc.gcmark = 1;
		break;
	case TLIST:
		marklist(n->nstore.u0.sl);
		break;
	case TCODE:
		marktree(n->nstore.u0.scc);
		break;
	}
}
Esempio n. 2
0
void
gc(void)
{
	int i;
	Lsym *f;
	Value *v;
	Gc *m, **p, *next;

	if(dogc < Mempergc)
		return;
	dogc = 0;

	/* Mark */
	for(m = gcl; m; m = m->gclink)
		m->gcmark = 0;

	/* Scan */
	for(i = 0; i < Hashsize; i++) {
		for(f = hash[i]; f; f = f->hash) {
			marktree(f->proc);
			if(f->lexval != Tid)
				continue;
			for(v = f->v; v; v = v->pop) {
				switch(v->type) {
				case TSTRING:
					v->vstore.u0.sstring->sgc.gcmark = 1;
					break;
				case TLIST:
					marklist(v->vstore.u0.sl);
					break;
				case TCODE:
					marktree(v->vstore.u0.scc);
					break;
				}
			}
		}
	}

	/* Free */
	p = &gcl;
	for(m = gcl; m; m = next) {
		next = m->gclink;
		if(m->gcmark == 0) {
			*p = next;
			free(m);	/* Sleazy reliance on my malloc */
		}
		else
			p = &m->gclink;
	}
}
Esempio n. 3
0
void
marklist(List *l)
{
	while(l) {
		l->lgc.gcmark = 1;
		switch(l->type) {
		case TSTRING:
			l->lstore.u0.sstring->sgc.gcmark = 1;
			break;
		case TLIST:
			marklist(l->lstore.u0.sl);
			break;
		case TCODE:
			marktree(l->lstore.u0.scc);
			break;
		}
		l = l->next;
	}
}
Esempio n. 4
0
File: main.c Progetto: Fluray/NxM
void
marklist(List *l)
{
	while(l) {
		l->gcmark = 1;
		switch(l->type) {
		case TSTRING:
			l->string->gcmark = 1;
			break;
		case TLIST:
			marklist(l->l);
			break;
		case TCODE:
			marktree(l->cc);
			break;
		}
		l = l->next;
	}
}