aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lstate.c b/lstate.c
index f4c9081d..8e7c8b86 100644
--- a/lstate.c
+++ b/lstate.c
@@ -77,12 +77,12 @@ typedef struct LG {
77** objects (GCtotalobjs - GCdebt) invariant and avoiding overflows in 77** objects (GCtotalobjs - GCdebt) invariant and avoiding overflows in
78** 'GCtotalobjs'. 78** 'GCtotalobjs'.
79*/ 79*/
80void luaE_setdebt (global_State *g, l_obj debt) { 80void luaE_setdebt (global_State *g, l_mem debt) {
81 l_obj tb = gettotalobjs(g); 81 l_mem tb = gettotalbytes(g);
82 lua_assert(tb > 0); 82 lua_assert(tb > 0);
83 if (debt > MAX_LOBJ - tb) 83 if (debt > MAX_LMEM - tb)
84 debt = MAX_LOBJ - tb; /* will make GCtotalobjs == MAX_LOBJ */ 84 debt = MAX_LMEM - tb; /* will make GCtotalbytes == MAX_LMEM */
85 g->GCtotalobjs = tb + debt; 85 g->GCtotalbytes = tb + debt;
86 g->GCdebt = debt; 86 g->GCdebt = debt;
87} 87}
88 88
@@ -269,8 +269,7 @@ static void close_state (lua_State *L) {
269 } 269 }
270 luaM_freearray(L, G(L)->strt.hash, cast_sizet(G(L)->strt.size)); 270 luaM_freearray(L, G(L)->strt.hash, cast_sizet(G(L)->strt.size));
271 freestack(L); 271 freestack(L);
272 lua_assert(g->GCtotalbytes == sizeof(LG)); 272 lua_assert(gettotalbytes(g) == sizeof(LG));
273 lua_assert(gettotalobjs(g) == 1);
274 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ 273 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */
275} 274}
276 275
@@ -379,7 +378,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) {
379 g->weak = g->ephemeron = g->allweak = NULL; 378 g->weak = g->ephemeron = g->allweak = NULL;
380 g->twups = NULL; 379 g->twups = NULL;
381 g->GCtotalbytes = sizeof(LG); 380 g->GCtotalbytes = sizeof(LG);
382 g->GCtotalobjs = 1;
383 g->GCmarked = 0; 381 g->GCmarked = 0;
384 g->GCdebt = 0; 382 g->GCdebt = 0;
385 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */ 383 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */