aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-19 09:43:35 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-19 09:43:35 -0300
commit9cdf6b7082c49e6bf7daf8c7c4c649bcaacf9fad (patch)
tree6543c7498f1c455cb2520411b17638bae50ca743 /lgc.c
parent3c1d415bd3fef686b27f853bdf3eaf1f0a9bb0be (diff)
downloadlua-9cdf6b7082c49e6bf7daf8c7c4c649bcaacf9fad.tar.gz
lua-9cdf6b7082c49e6bf7daf8c7c4c649bcaacf9fad.tar.bz2
lua-9cdf6b7082c49e6bf7daf8c7c4c649bcaacf9fad.zip
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.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lgc.c b/lgc.c
index aa6921bc..6562c928 100644
--- a/lgc.c
+++ b/lgc.c
@@ -794,10 +794,11 @@ static GCObject **sweeptolive (lua_State *L, GCObject **p) {
794*/ 794*/
795static void checkSizes (lua_State *L, global_State *g) { 795static void checkSizes (lua_State *L, global_State *g) {
796 if (!g->gcemergency) { 796 if (!g->gcemergency) {
797 l_mem olddebt = g->GCdebt; 797 if (g->strt.nuse < g->strt.size / 4) { /* string table too big? */
798 if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ 798 l_mem olddebt = g->GCdebt;
799 luaS_resize(L, g->strt.size / 2); 799 luaS_resize(L, g->strt.size / 2);
800 g->GCestimate += g->GCdebt - olddebt; /* correct estimate */ 800 g->GCestimate += g->GCdebt - olddebt; /* correct estimate */
801 }
801 } 802 }
802} 803}
803 804