From dad808a73a98a23729614b8814728d76b4e5d577 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 29 Sep 2000 09:42:13 -0300 Subject: new way to count `nblocks' for GC (try to count bytes). --- ldo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ldo.c') diff --git a/ldo.c b/ldo.c index 8f49b595..283c3cdf 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.96 2000/09/12 13:47:39 roberto Exp roberto $ +** $Id: ldo.c,v 1.97 2000/09/25 16:22:42 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -33,6 +33,7 @@ void luaD_init (lua_State *L, int stacksize) { L->stack = luaM_newvector(L, stacksize+EXTRA_STACK, TObject); + L->nblocks += stacksize*sizeof(TObject); L->stack_last = L->stack+(stacksize-1); L->stacksize = stacksize; L->Cbase = L->top = L->stack; @@ -248,10 +249,12 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) { luaC_checkGC(L); old_blocks = L->nblocks; status = luaD_runprotected(L, f_parser, &p); - if (status == LUA_ERRRUN) /* an error occurred: correct error code */ + if (status == 0) { + /* add new memory to threshould (as it probably will stay) */ + L->GCthreshold += (L->nblocks - old_blocks); + } + else if (status == LUA_ERRRUN) /* an error occurred: correct error code */ status = LUA_ERRSYNTAX; - /* add new memory to threshould (as it probably will stay) */ - L->GCthreshold += (L->nblocks - old_blocks); return status; } -- cgit v1.2.3-55-g6feb