lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


云风 Cloud Wu <cloudwu@gmail.com> 于2020年11月4日周三 上午11:01写道:
>
> Sorry , I should not change the macro stacksize. The patch should be :
>
> --- a/src/ldo.c
> +++ b/src/ldo.c
> @@ -192,7 +192,7 @@ int luaD_reallocstack (lua_State *L, int newsize,
> int raiseerror) {
>      else return 0;  /* do not raise an error */
>    }
>    for (; lim < newsize; lim++)
> -    setnilvalue(s2v(newstack + lim)); /* erase new segment */
> +    setnilvalue(s2v(newstack + lim + EXTRA_STACK)); /* erase new segment */
>    correctstack(L, L->stack, newstack);
>    L->stack = newstack;
>    L->stack_last = L->stack + newsize;
>

I'm not sure if it is necessary to init the extra slots of the stack,
but it seems that keeping values initialized would be better .

--- a/lstate.c
+++ b/lstate.c
@@ -181,7 +181,7 @@ static void stack_init (lua_State *L1, lua_State *L) {
int i; CallInfo *ci;
/* initialize stack array */
L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue);
- for (i = 0; i < BASIC_STACK_SIZE; i++)
+ for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)



-- 
http://blog.codingnow.com