lua_pushstring(L,funcname);
lua_getglobal(L,-1);
lua_pushnumber(L,a);
lua_pcall(L,1,0,0);
有可能使lua堆栈不断增长,所以如果不能确定
堆栈里有什么时,可以用下面的方法来保证堆栈大小。
int top = lua_gettop(luaState);
...
lua_settop(luaState,top);
Lua脚本中堆栈管理与调用Lua函数实践
lua_pushstring(L,funcname);
lua_getglobal(L,-1);
lua_pushnumber(L,a);
lua_pcall(L,1,0,0);
有可能使lua堆栈不断增长,所以如果不能确定
堆栈里有什么时,可以用下面的方法来保证堆栈大小。
int top = lua_gettop(luaState);
...
lua_settop(luaState,top);
1884

被折叠的 条评论
为什么被折叠?