"fixed" objects kept in a separated list (instead of being kept in
'allgc' list with a bit marking them)
This commit is contained in:
13
lgc.c
13
lgc.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lgc.c,v 2.148 2013/08/20 17:46:34 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.149 2013/08/21 19:21:16 roberto Exp roberto $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -189,6 +189,16 @@ void luaC_checkupvalcolor (global_State *g, UpVal *uv) {
|
||||
}
|
||||
|
||||
|
||||
void luaC_fix (lua_State *L, GCObject *o) {
|
||||
global_State *g = G(L);
|
||||
lua_assert(g->allgc == o);
|
||||
white2gray(o);
|
||||
g->allgc = o->gch.next; /* remove object from 'allgc' list */
|
||||
o->gch.next = g->fixedgc; /* link it to 'fixedgc' list */
|
||||
g->fixedgc = o;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** create a new collectable object (with given type and size) and link
|
||||
** it to '*list'. 'offset' tells how many bytes to allocate before the
|
||||
@@ -927,6 +937,7 @@ void luaC_freeallobjects (lua_State *L) {
|
||||
g->gckind = KGC_NORMAL;
|
||||
sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */
|
||||
sweepwholelist(L, &g->allgc);
|
||||
sweepwholelist(L, &g->fixedgc); /* collect fixed objects */
|
||||
lua_assert(g->strt.nuse == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user