aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-11 12:53:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-11 12:53:29 -0300
commit3ca9af51a4f060cf2178901a67a21f8269af3224 (patch)
tree4f1bb541280aa8b4960b16d0925eca60adb2b1a8 /ltable.c
parentc7b89dd28097296bbc14d9b47b4cea72514b2b76 (diff)
downloadlua-3ca9af51a4f060cf2178901a67a21f8269af3224.tar.gz
lua-3ca9af51a4f060cf2178901a67a21f8269af3224.tar.bz2
lua-3ca9af51a4f060cf2178901a67a21f8269af3224.zip
emergency garbage collector (core forces a GC when allocation fails)
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ltable.c b/ltable.c
index b68d1486..b3ad833c 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp roberto $ 2** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -294,7 +294,7 @@ static void setnodevector (lua_State *L, Table *t, int size) {
294} 294}
295 295
296 296
297static void resize (lua_State *L, Table *t, int nasize, int nhsize) { 297void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
298 int i; 298 int i;
299 int oldasize = t->sizearray; 299 int oldasize = t->sizearray;
300 int oldhsize = t->lsizenode; 300 int oldhsize = t->lsizenode;
@@ -326,7 +326,7 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
326 326
327void luaH_resizearray (lua_State *L, Table *t, int nasize) { 327void luaH_resizearray (lua_State *L, Table *t, int nasize) {
328 int nsize = (t->node == dummynode) ? 0 : sizenode(t); 328 int nsize = (t->node == dummynode) ? 0 : sizenode(t);
329 resize(L, t, nasize, nsize); 329 luaH_resize(L, t, nasize, nsize);
330} 330}
331 331
332 332
@@ -345,7 +345,7 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) {
345 /* compute new size for array part */ 345 /* compute new size for array part */
346 na = computesizes(nums, &nasize); 346 na = computesizes(nums, &nasize);
347 /* resize the table to new computed sizes */ 347 /* resize the table to new computed sizes */
348 resize(L, t, nasize, totaluse - na); 348 luaH_resize(L, t, nasize, totaluse - na);
349} 349}
350 350
351 351
@@ -355,18 +355,14 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) {
355*/ 355*/
356 356
357 357
358Table *luaH_new (lua_State *L, int narray, int nhash) { 358Table *luaH_new (lua_State *L) {
359 Table *t = luaM_new(L, Table); 359 Table *t = luaM_new(L, Table);
360 luaC_link(L, obj2gco(t), LUA_TTABLE); 360 luaC_link(L, obj2gco(t), LUA_TTABLE);
361 t->metatable = NULL; 361 t->metatable = NULL;
362 t->flags = cast_byte(~0); 362 t->flags = cast_byte(~0);
363 /* temporary values (kept only if some malloc fails) */
364 t->array = NULL; 363 t->array = NULL;
365 t->sizearray = 0; 364 t->sizearray = 0;
366 t->lsizenode = 0; 365 setnodevector(L, t, 0);
367 t->node = cast(Node *, dummynode);
368 setarrayvector(L, t, narray);
369 setnodevector(L, t, nhash);
370 return t; 366 return t;
371} 367}
372 368