/* Try to grow the stack by at least 'n' elements. when 'raiseerror' is true, raises any error; otherwise, return 0 in case of errors.  */
int luaD_growstack(lua_State *L, int n, int raiseerror)
/* Try to grow the stack by at least 'n' elements. when 'raiseerror' is true, raises any error; otherwise, return 0 in case of errors.  */
int luaD_growstack(lua_State *L, int n, int raiseerror)
{
    lua_assert(stacksize(L) == ERRORSTACKSIZE);
    if (raiseerror)
      luaD_throw(L, LUA_ERRERR);
    return 0;
  }
  else {
    int newsize = 2 * size;
    int needed = cast_int(L->top - L->stack) + n;
    if (newsize > LUAI_MAXSTACK)
      newsize = LUAI_MAXSTACK;
    if (newsize < needed)
      newsize = needed;
    if (l_likely(newsize <= LUAI_MAXSTACK))
      return luaD_reallocstack(L, newsize, raiseerror);
    else {
      luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror);
      if (raiseerror)
        luaG_runerror(L, "stack overflow");
      return 0;
    }
  }
}