コード例 #1
0
ファイル: main.c プロジェクト: JamesLinus/inferno
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;
	}
}
コード例 #2
0
ファイル: main.c プロジェクト: JamesLinus/inferno
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;
	}
}
コード例 #3
0
ファイル: main.c プロジェクト: JamesLinus/inferno
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;
	}
}
コード例 #4
0
ファイル: main.c プロジェクト: 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;
	}
}
コード例 #5
0
ファイル: trusts_commands.c プロジェクト: quakenet/newserv
static void displaygroup(nick *sender, trustgroup *tg, int showchildren) {
  trusthost *th, **p2;
  unsigned int marker;
  array parents;
  int i;
  time_t t = getnettime();

  /* abusing the ternary operator a bit :( */
  controlreply(sender, "Name             : %s", tg->name->content);
  controlreply(sender, "Trusted for      : %s", formatlimit(tg->trustedfor));
  controlreply(sender, "Currently using  : %d", tg->count);
  controlreply(sender, "Clients per user : %s", formatlimit(tg->maxperident));
  controlreply(sender, "Flags            : %s", formatflags(tg->flags));
  controlreply(sender, "Contact          : %s", tg->contact->content);
  controlreply(sender, "Expires in       : %s", (tg->expires)?((tg->expires>t)?longtoduration(tg->expires - t, 2):"the past (will be removed during next cleanup)"):"never");
  controlreply(sender, "Created by       : %s", tg->createdby->content);
  controlreply(sender, "Comment          : %s", tg->comment->content);
  controlreply(sender, "ID               : %u", tg->id);
  controlreply(sender, "Last used        : %s", (tg->count>0)?"(now)":((tg->lastseen>0)?trusts_timetostr(tg->lastseen):"(never)"));
  controlreply(sender, "Max usage        : %d", tg->maxusage);
  controlreply(sender, "Last max reset   : %s", tg->lastmaxusereset?trusts_timetostr(tg->lastmaxusereset):"(never)");

  controlreply(sender, "---");
  controlreply(sender, "Attributes: * (has hidden children, show with -v), > (belongs to this trust group)");
  controlreply(sender, "Host                            Current    Max        Last seen             Max per Node    Node Mask      Group ID   Group name");

  marker = nextthmarker();
  array_init(&parents, sizeof(trusthost *));

  for(th=tg->hosts;th;th=th->next)
    marktree(&parents, marker, th, showchildren);

  p2 = (trusthost **)(parents.content);
  for(i=0;i<parents.cursi;i++)
    outputtree(sender, marker, tg, p2[i], 0, showchildren);

  array_free(&parents);
}