From 3ca9af51a4f060cf2178901a67a21f8269af3224 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 11 Jul 2006 12:53:29 -0300 Subject: emergency garbage collector (core forces a GC when allocation fails) --- ltable.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index b68d1486..b3ad833c 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp roberto $ +** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -294,7 +294,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { } -static void resize (lua_State *L, Table *t, int nasize, int nhsize) { +void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { int i; int oldasize = t->sizearray; int oldhsize = t->lsizenode; @@ -326,7 +326,7 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) { void luaH_resizearray (lua_State *L, Table *t, int nasize) { int nsize = (t->node == dummynode) ? 0 : sizenode(t); - resize(L, t, nasize, nsize); + luaH_resize(L, t, nasize, nsize); } @@ -345,7 +345,7 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { /* compute new size for array part */ na = computesizes(nums, &nasize); /* resize the table to new computed sizes */ - resize(L, t, nasize, totaluse - na); + luaH_resize(L, t, nasize, totaluse - na); } @@ -355,18 +355,14 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { */ -Table *luaH_new (lua_State *L, int narray, int nhash) { +Table *luaH_new (lua_State *L) { Table *t = luaM_new(L, Table); luaC_link(L, obj2gco(t), LUA_TTABLE); t->metatable = NULL; t->flags = cast_byte(~0); - /* temporary values (kept only if some malloc fails) */ t->array = NULL; t->sizearray = 0; - t->lsizenode = 0; - t->node = cast(Node *, dummynode); - setarrayvector(L, t, narray); - setnodevector(L, t, nhash); + setnodevector(L, t, 0); return t; } -- cgit v1.2.3-55-g6feb