diff options
Diffstat (limited to '')
| -rw-r--r-- | lgc.c | 13 |
1 files changed, 9 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.239 2017/11/23 19:29:04 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.240 2017/11/30 15:37:16 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -816,14 +816,19 @@ static GCObject **sweeptolive (lua_State *L, GCObject **p) { | |||
| 816 | */ | 816 | */ |
| 817 | 817 | ||
| 818 | /* | 818 | /* |
| 819 | ** If possible, shrink string table | 819 | ** If possible, shrink string table (protected from memory errors). |
| 820 | */ | 820 | */ |
| 821 | static void shrinkstrtable (lua_State *L, void *ud) { | ||
| 822 | luaS_resize(L, *cast(int*, ud) / 2); | ||
| 823 | } | ||
| 824 | |||
| 825 | |||
| 821 | static void checkSizes (lua_State *L, global_State *g) { | 826 | static void checkSizes (lua_State *L, global_State *g) { |
| 822 | if (!g->gcemergency) { | 827 | if (!g->gcemergency) { |
| 823 | l_mem olddebt = g->GCdebt; | 828 | l_mem olddebt = g->GCdebt; |
| 824 | if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ | 829 | if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ |
| 825 | luaS_resize(L, g->strt.size / 2); /* shrink it a little */ | 830 | luaD_rawrunprotected(L, &shrinkstrtable, &g->strt.size); |
| 826 | g->GCestimate += g->GCdebt - olddebt; /* update estimate */ | 831 | g->GCestimate += g->GCdebt - olddebt; /* correct estimate */ |
| 827 | } | 832 | } |
| 828 | } | 833 | } |
| 829 | 834 | ||
