diff options
Diffstat (limited to 'table.c')
-rw-r--r-- | table.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.68 1997/04/07 14:48:53 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.69 1997/05/14 18:38:29 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include "luamem.h" | 8 | #include "luamem.h" |
9 | #include "auxlib.h" | 9 | #include "auxlib.h" |
@@ -29,7 +29,7 @@ Word lua_nconstant = 0; | |||
29 | static Long lua_maxconstant = 0; | 29 | static Long lua_maxconstant = 0; |
30 | 30 | ||
31 | 31 | ||
32 | #define GARBAGE_BLOCK 50 | 32 | #define GARBAGE_BLOCK 100 |
33 | 33 | ||
34 | 34 | ||
35 | void luaI_initsymbol (void) | 35 | void luaI_initsymbol (void) |
@@ -189,7 +189,7 @@ static void markall (void) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | static void lua_collectgarbage (void) | 192 | long lua_collectgarbage (long limit) |
193 | { | 193 | { |
194 | long recovered = 0; | 194 | long recovered = 0; |
195 | Hash *freetable; | 195 | Hash *freetable; |
@@ -199,21 +199,22 @@ static void lua_collectgarbage (void) | |||
199 | freetable = luaI_hashcollector(&recovered); | 199 | freetable = luaI_hashcollector(&recovered); |
200 | freestr = luaI_strcollector(&recovered); | 200 | freestr = luaI_strcollector(&recovered); |
201 | freefunc = luaI_funccollector(&recovered); | 201 | freefunc = luaI_funccollector(&recovered); |
202 | gc_block = 2*(gc_block-recovered); | ||
203 | gc_nentity -= recovered; | 202 | gc_nentity -= recovered; |
203 | gc_block = (limit == 0) ? 2*(gc_block-recovered) : gc_nentity+limit; | ||
204 | luaI_hashcallIM(freetable); | 204 | luaI_hashcallIM(freetable); |
205 | luaI_strcallIM(freestr); | 205 | luaI_strcallIM(freestr); |
206 | call_nilIM(); | 206 | call_nilIM(); |
207 | luaI_hashfree(freetable); | 207 | luaI_hashfree(freetable); |
208 | luaI_strfree(freestr); | 208 | luaI_strfree(freestr); |
209 | luaI_funcfree(freefunc); | 209 | luaI_funcfree(freefunc); |
210 | return recovered; | ||
210 | } | 211 | } |
211 | 212 | ||
212 | 213 | ||
213 | void lua_pack (void) | 214 | void lua_pack (void) |
214 | { | 215 | { |
215 | if (gc_nentity++ >= gc_block) | 216 | if (++gc_nentity >= gc_block) |
216 | lua_collectgarbage(); | 217 | lua_collectgarbage(0); |
217 | } | 218 | } |
218 | 219 | ||
219 | 220 | ||