diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-19 09:43:35 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-19 09:43:35 -0300 |
commit | 9cdf6b7082c49e6bf7daf8c7c4c649bcaacf9fad (patch) | |
tree | 6543c7498f1c455cb2520411b17638bae50ca743 /lgc.c | |
parent | 3c1d415bd3fef686b27f853bdf3eaf1f0a9bb0be (diff) | |
download | lua-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.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -794,10 +794,11 @@ static GCObject **sweeptolive (lua_State *L, GCObject **p) { | |||
794 | */ | 794 | */ |
795 | static void checkSizes (lua_State *L, global_State *g) { | 795 | static 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 | ||