Ejemplo n.º 1
0
int32 lua_collectgarbage (int32 limit)
{
  int32 recovered = L->nblocks;  /* to subtract nblocks after gc */
  Hash *freetable;
  TaggedString *freestr;
  TProtoFunc *freefunc;
  Closure *freeclos;
  markall();
  invalidaterefs();
  freestr = luaS_collector();
  freetable = (Hash *)listcollect(&(L->roottable));
  freefunc = (TProtoFunc *)listcollect(&(L->rootproto));
  freeclos = (Closure *)listcollect(&(L->rootcl));
  L->GCthreshold *= 4;  /* to avoid GC during GC */
  luaC_hashcallIM(freetable);  /* GC tag methods for tables */
  luaC_strcallIM(freestr);  /* GC tag methods for userdata */
  luaD_gcIM(&luaO_nilobject);  /* GC tag method for nil (signal end of GC) */
  luaH_free(freetable);
  luaS_free(freestr);
  luaF_freeproto(freefunc);
  luaF_freeclosure(freeclos);
  recovered = recovered-L->nblocks;
  L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit;
  return recovered;
}
Ejemplo n.º 2
0
/*
 * Convert the user string of message numbers and
 * store the numbers into vector.
 *
 * Returns the count of messages picked up or -1 on error.
 */
int
getmsglist(char *buf, int *vector, int flags)
{
	int *ip;
	struct message *mp;

	if (msgCount == 0) {
		*vector = 0;
		return (0);
	}
	if (markall(buf, flags) < 0)
		return (-1);
	ip = vector;
	for (mp = &message[0]; mp < &message[msgCount]; mp++)
		if (mp->m_flag & MMARK)
			*ip++ = mp - &message[0] + 1;
	*ip = 0;
	return (ip - vector);
}