mirror of
https://github.com/lua/lua
synced 2025-04-08 14:02:56 +03:00
lua_stackspace' replaced by
lua_checkstack'
This commit is contained in:
parent
8f837e83b2
commit
c16a35d669
19
lapi.c
19
lapi.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.174 2002/02/14 21:46:13 roberto Exp roberto $
|
** $Id: lapi.c,v 1.175 2002/03/04 21:29:41 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -80,8 +80,18 @@ void luaA_pushobject (lua_State *L, const TObject *o) {
|
|||||||
incr_top(L);
|
incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUA_API int lua_stackspace (lua_State *L) {
|
|
||||||
return (L->stack_last - L->top);
|
LUA_API int lua_checkstack (lua_State *L, int size) {
|
||||||
|
int res;
|
||||||
|
lua_lock(L);
|
||||||
|
if ((L->top - L->stack) + size >= LUA_MAXSTACK)
|
||||||
|
res = 0; /* stack overflow */
|
||||||
|
luaD_checkstack(L, size);
|
||||||
|
if (L->ci->top < L->top + size)
|
||||||
|
L->ci->top = L->top + size;
|
||||||
|
res = 1;
|
||||||
|
lua_unlock(L);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -667,8 +677,7 @@ LUA_API int lua_pushupvalues (lua_State *L) {
|
|||||||
func = (L->ci->base - 1);
|
func = (L->ci->base - 1);
|
||||||
api_check(L, iscfunction(func));
|
api_check(L, iscfunction(func));
|
||||||
n = clvalue(func)->c.nupvalues;
|
n = clvalue(func)->c.nupvalues;
|
||||||
if (LUA_MINSTACK+n > lua_stackspace(L))
|
luaD_checkstack(L, n + LUA_MINSTACK);
|
||||||
luaD_error(L, "stack overflow");
|
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
setobj(L->top, &clvalue(func)->c.upvalue[i]);
|
setobj(L->top, &clvalue(func)->c.upvalue[i]);
|
||||||
L->top++;
|
L->top++;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
|
** $Id: lauxlib.c,v 1.60 2002/02/14 21:41:53 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -67,7 +67,7 @@ static void tag_error (lua_State *L, int narg, int tag) {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) {
|
LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) {
|
||||||
if (space > lua_stackspace(L))
|
if (!lua_checkstack(L, space))
|
||||||
luaL_verror(L, "stack overflow (%.30s)", mes);
|
luaL_verror(L, "stack overflow (%.30s)", mes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
lua.h
4
lua.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
|
** $Id: lua.h,v 1.121 2002/02/14 21:40:13 roberto Exp roberto $
|
||||||
** Lua - An Extensible Extension Language
|
** Lua - An Extensible Extension Language
|
||||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||||
** e-mail: info@lua.org
|
** e-mail: info@lua.org
|
||||||
@ -109,7 +109,7 @@ LUA_API void lua_pushvalue (lua_State *L, int index);
|
|||||||
LUA_API void lua_remove (lua_State *L, int index);
|
LUA_API void lua_remove (lua_State *L, int index);
|
||||||
LUA_API void lua_insert (lua_State *L, int index);
|
LUA_API void lua_insert (lua_State *L, int index);
|
||||||
LUA_API void lua_replace (lua_State *L, int index);
|
LUA_API void lua_replace (lua_State *L, int index);
|
||||||
LUA_API int lua_stackspace (lua_State *L);
|
LUA_API int lua_checkstack (lua_State *L, int size);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user