aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lgc.c b/lgc.c
index 94d801ab..6beaa55b 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.9 2004/08/24 20:12:06 roberto Exp roberto $ 2** $Id: lgc.c,v 2.10 2004/08/30 13:44:44 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -239,14 +239,17 @@ static void traverseclosure (global_State *g, Closure *cl) {
239 239
240 240
241static void checkstacksizes (lua_State *L, StkId max) { 241static void checkstacksizes (lua_State *L, StkId max) {
242 int used = L->ci - L->base_ci; /* number of `ci' in use */ 242 int ci_used = L->ci - L->base_ci; /* number of `ci' in use */
243 if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) 243 int s_used = max - L->stack; /* part of stack in use */
244 if (L->size_ci > LUA_MAXCALLS) /* handling overflow? */
245 return; /* do not touch the stacks */
246 if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
244 luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ 247 luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
245 else condhardstacktests(luaD_reallocCI(L, L->size_ci)); 248 condhardstacktests(luaD_reallocCI(L, ci_used + 1));
246 used = max - L->stack; /* part of stack in use */ 249 if (4*s_used < L->stacksize &&
247 if (4*used < L->stacksize && 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) 250 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
248 luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ 251 luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
249 else condhardstacktests(luaD_reallocstack(L, L->stacksize)); 252 condhardstacktests(luaD_reallocstack(L, s_used));
250} 253}
251 254
252 255