diff options
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.50 2009/04/17 14:28:06 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.51 2009/04/28 19:04:36 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 | */ |
@@ -589,8 +589,12 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { | |||
589 | 589 | ||
590 | static void checkSizes (lua_State *L) { | 590 | static void checkSizes (lua_State *L) { |
591 | global_State *g = G(L); | 591 | global_State *g = G(L); |
592 | if (g->strt.nuse < cast(lu_int32, g->strt.size)) | 592 | if (g->strt.nuse < cast(lu_int32, g->strt.size)) { |
593 | luaS_resize(L, 1 << luaO_ceillog2(g->strt.nuse)); | 593 | /* size could be the smaller power of 2 larger than 'nuse' */ |
594 | int size = 1 << luaO_ceillog2(g->strt.nuse); | ||
595 | if (size < g->strt.size) /* current table too large? */ | ||
596 | luaS_resize(L, size); /* shrink it */ | ||
597 | } | ||
594 | luaZ_freebuffer(L, &g->buff); | 598 | luaZ_freebuffer(L, &g->buff); |
595 | } | 599 | } |
596 | 600 | ||