diff options
Diffstat (limited to 'table.c')
-rw-r--r-- | table.c | 17 |
1 files changed, 12 insertions, 5 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.38 1995/11/03 15:30:50 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.39 1996/01/09 20:23:19 roberto Exp $"; |
7 | 7 | ||
8 | /*#include <string.h>*/ | 8 | /*#include <string.h>*/ |
9 | 9 | ||
@@ -178,12 +178,9 @@ int lua_markobject (Object *o) | |||
178 | ** Garbage collection. | 178 | ** Garbage collection. |
179 | ** Delete all unused strings and arrays. | 179 | ** Delete all unused strings and arrays. |
180 | */ | 180 | */ |
181 | void lua_pack (void) | 181 | Long luaI_collectgarbage (void) |
182 | { | 182 | { |
183 | static Long block = GARBAGE_BLOCK; /* when garbage collector will be called */ | ||
184 | static Long nentity = 0; /* counter of new entities (strings and arrays) */ | ||
185 | Long recovered = 0; | 183 | Long recovered = 0; |
186 | if (nentity++ < block) return; | ||
187 | lua_travstack(lua_markobject); /* mark stack objects */ | 184 | lua_travstack(lua_markobject); /* mark stack objects */ |
188 | lua_travsymbol(lua_markobject); /* mark symbol table objects */ | 185 | lua_travsymbol(lua_markobject); /* mark symbol table objects */ |
189 | luaI_travlock(lua_markobject); /* mark locked objects */ | 186 | luaI_travlock(lua_markobject); /* mark locked objects */ |
@@ -191,6 +188,16 @@ void lua_pack (void) | |||
191 | recovered += lua_strcollector(); | 188 | recovered += lua_strcollector(); |
192 | recovered += lua_hashcollector(); | 189 | recovered += lua_hashcollector(); |
193 | recovered += luaI_funccollector(); | 190 | recovered += luaI_funccollector(); |
191 | return recovered; | ||
192 | } | ||
193 | |||
194 | void lua_pack (void) | ||
195 | { | ||
196 | static Long block = GARBAGE_BLOCK; /* when garbage collector will be called */ | ||
197 | static Long nentity = 0; /* counter of new entities (strings and arrays) */ | ||
198 | Long recovered = 0; | ||
199 | if (nentity++ < block) return; | ||
200 | recovered = luaI_collectgarbage(); | ||
194 | nentity = 0; /* reset counter */ | 201 | nentity = 0; /* reset counter */ |
195 | block=(16*block-7*recovered)/12; /* adapt block size */ | 202 | block=(16*block-7*recovered)/12; /* adapt block size */ |
196 | if (block < MIN_GARBAGE_BLOCK) block = MIN_GARBAGE_BLOCK; | 203 | if (block < MIN_GARBAGE_BLOCK) block = MIN_GARBAGE_BLOCK; |