Some details in 'lmem.c' and 'lgc.c'
- Several new comments in 'lmem.c'. - Both 'luaM_growaux_' and 'luaM_shrinkvector_' use 'luaM_saferealloc_' to check for errors. Moreover, the use of 'luaM_saferealloc_' makes 'luaM_shrinkvector_' try again if shrink fails (which can happen now). - In 'checkSizes', save old debt only when needed.
This commit is contained in:
7
lgc.c
7
lgc.c
@@ -794,10 +794,11 @@ static GCObject **sweeptolive (lua_State *L, GCObject **p) {
|
||||
*/
|
||||
static void checkSizes (lua_State *L, global_State *g) {
|
||||
if (!g->gcemergency) {
|
||||
l_mem olddebt = g->GCdebt;
|
||||
if (g->strt.nuse < g->strt.size / 4) /* string table too big? */
|
||||
if (g->strt.nuse < g->strt.size / 4) { /* string table too big? */
|
||||
l_mem olddebt = g->GCdebt;
|
||||
luaS_resize(L, g->strt.size / 2);
|
||||
g->GCestimate += g->GCdebt - olddebt; /* correct estimate */
|
||||
g->GCestimate += g->GCdebt - olddebt; /* correct estimate */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user