aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-03 16:37:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-03 16:37:13 -0300
commit76953316d1283ab6324b59b914ef53a521408444 (patch)
tree41d34e962db7c645bd56f2dc688fe110d5df46a6 /lstate.c
parent3d2bd1359d17228b62752f6edae86b6a1579c6d4 (diff)
downloadlua-76953316d1283ab6324b59b914ef53a521408444.tar.gz
lua-76953316d1283ab6324b59b914ef53a521408444.tar.bz2
lua-76953316d1283ab6324b59b914ef53a521408444.zip
Added a counter of the total number of existing objects
It may simplify the control of the garbage collector.
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lstate.c b/lstate.c
index 1fbefb4b..3091a00e 100644
--- a/lstate.c
+++ b/lstate.c
@@ -279,6 +279,7 @@ static void close_state (lua_State *L) {
279 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); 279 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size);
280 freestack(L); 280 freestack(L);
281 lua_assert(gettotalbytes(g) == sizeof(LG)); 281 lua_assert(gettotalbytes(g) == sizeof(LG));
282 lua_assert(g->totalobjs == 1);
282 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ 283 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */
283} 284}
284 285
@@ -387,6 +388,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
387 g->weak = g->ephemeron = g->allweak = NULL; 388 g->weak = g->ephemeron = g->allweak = NULL;
388 g->twups = NULL; 389 g->twups = NULL;
389 g->totalbytes = sizeof(LG); 390 g->totalbytes = sizeof(LG);
391 g->totalobjs = 1;
390 g->GCdebt = 0; 392 g->GCdebt = 0;
391 g->lastatomic = 0; 393 g->lastatomic = 0;
392 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */ 394 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */